chore: update zsh configs (aliases, completion, external, plugins, fzf, zprofile, zshenv, zshrc)
This commit is contained in:
parent
30cbf8d1c7
commit
4c4419cf30
8 changed files with 570 additions and 240 deletions
|
|
@ -1,58 +1,77 @@
|
||||||
# General aliases
|
#!/usr/bin/env zsh
|
||||||
|
# Modern shell aliases and functions
|
||||||
|
|
||||||
|
# Navigation shortcuts
|
||||||
alias grep="grep --color=auto"
|
alias grep="grep --color=auto"
|
||||||
alias ..="cd .."
|
alias ..="cd .."
|
||||||
alias ...="cd ../.."
|
alias ...="cd ../.."
|
||||||
alias ....="cd ../../.."
|
alias ....="cd ../../.."
|
||||||
alias .....="cd ../../../.."
|
alias .....="cd ../../../.."
|
||||||
|
alias -- -='cd -'
|
||||||
|
alias md='mkdir -p'
|
||||||
|
alias rd='rmdir'
|
||||||
|
|
||||||
# Use Neovim if available
|
# Modern directory management
|
||||||
if command -v nvim >/dev/null; then
|
mkcd() { [[ -z "$1" ]] && { echo "Usage: mkcd <directory>"; return 1 }; mkdir -p "$1" && cd "$1" }
|
||||||
alias v='nvim'
|
cd..() { local count="${1:-1}"; for ((i=0; i<count; i++)); do cd ..; done }
|
||||||
|
|
||||||
|
# Platform-specific optimizations
|
||||||
|
if [[ "$_ARCH" == "arm64" ]]; then
|
||||||
|
alias clang++="clang++ -arch arm64"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Enhanced ls with eza
|
# Modern development tools
|
||||||
if command -v eza >/dev/null; then
|
command -v nvim &>/dev/null && alias v='nvim'
|
||||||
|
command -v code &>/dev/null && alias vs='code .'
|
||||||
|
command -v lazydocker &>/dev/null && alias lzd='lazydocker'
|
||||||
|
command -v lazygit &>/dev/null && alias lzg='lazygit'
|
||||||
|
command -v kubectl &>/dev/null && alias k='kubectl'
|
||||||
|
command -v terraform &>/dev/null && alias tf='terraform'
|
||||||
|
command -v make &>/dev/null && alias m='make'
|
||||||
|
|
||||||
|
# Docker aliases
|
||||||
|
if command -v docker &>/dev/null; then
|
||||||
|
alias d='docker'
|
||||||
|
alias dc='docker-compose'
|
||||||
|
alias dce='docker-compose exec'
|
||||||
|
alias dcb='docker-compose build'
|
||||||
|
alias dcd='docker-compose down'
|
||||||
|
alias dcu='docker-compose up'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Enhanced ls (eza)
|
||||||
|
if command -v eza &>/dev/null; then
|
||||||
alias ls='eza --group-directories-first --color=auto'
|
alias ls='eza --group-directories-first --color=auto'
|
||||||
alias la='eza -a --group-directories-first --color=auto'
|
alias la='eza -a --group-directories-first --color=auto'
|
||||||
alias ll='eza -lh --group-directories-first --color=auto'
|
alias ll='eza -lh --group-directories-first --color=auto'
|
||||||
alias lla='eza -la --group-directories-first --color=auto'
|
alias lla='eza -la --group-directories-first --color=auto'
|
||||||
alias l='eza --classify'
|
|
||||||
alias lt='eza -lt modified --sort newest'
|
alias lt='eza -lt modified --sort newest'
|
||||||
alias lS='eza -lS --group-directories-first --color=auto'
|
|
||||||
alias tree='eza --tree --level=5'
|
alias tree='eza --tree --level=5'
|
||||||
alias lg='eza --git'
|
alias lg='eza -lg --git --group-directories-first'
|
||||||
|
else
|
||||||
|
# Fallback to ls
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
alias la='ls -A --color=auto'
|
||||||
|
alias ll='ls -lh --color=auto'
|
||||||
|
alias lla='ls -lAh --color=auto'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Bat for pretty `cat` and help
|
# Enhanced cat (bat)
|
||||||
if command -v bat >/dev/null; then
|
if command -v bat &>/dev/null; then
|
||||||
# Define a function instead of aliasing inside same unit
|
cat() { command bat --paging=never "$@"; }
|
||||||
function cat() {
|
bathelp() { bat --plain --language=help; }
|
||||||
command bat --paging=never "$@"
|
help() { "$@" --help 2>&1 | bathelp; }
|
||||||
}
|
|
||||||
|
|
||||||
function bathelp() {
|
|
||||||
bat --plain --language=help
|
|
||||||
}
|
|
||||||
|
|
||||||
function help() {
|
|
||||||
"$@" --help 2>&1 | bathelp
|
|
||||||
}
|
|
||||||
|
|
||||||
# Global aliases for help text
|
|
||||||
alias -g ':h'='-h 2>&1 | bat --language=help --style=plain'
|
alias -g ':h'='-h 2>&1 | bat --language=help --style=plain'
|
||||||
alias -g ':help'='--help 2>&1 | bat --language=help --style=plain'
|
alias -g ':help'='--help 2>&1 | bat --language=help --style=plain'
|
||||||
|
alias catp='bat --style=plain'
|
||||||
|
else
|
||||||
|
# Fallback functions if bat not available
|
||||||
|
help() { "$@" --help 2>&1 | less; }
|
||||||
|
alias -g ':h'='-h 2>&1 | less'
|
||||||
|
alias -g ':help'='--help 2>&1 | less'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use trash instead of rm on non-Windows systems
|
# Modern Git aliases
|
||||||
if [[ "$(uname -s)" != MINGW* && "$(uname -s)" != CYGWIN* ]]; then
|
|
||||||
alias rm='trash'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Dev tools
|
|
||||||
alias lzd='lazydocker'
|
|
||||||
alias v='nvim' # This can be overridden in check_aliases if nvim doesn't exist
|
|
||||||
|
|
||||||
# Git aliases
|
|
||||||
alias gs='git status'
|
alias gs='git status'
|
||||||
alias gc='git commit'
|
alias gc='git commit'
|
||||||
alias gcm='git commit -m'
|
alias gcm='git commit -m'
|
||||||
|
|
@ -63,4 +82,75 @@ alias gp='git push'
|
||||||
alias gl='git log --oneline --graph --decorate'
|
alias gl='git log --oneline --graph --decorate'
|
||||||
alias gi='git init'
|
alias gi='git init'
|
||||||
alias gcl='git clone'
|
alias gcl='git clone'
|
||||||
|
alias ga='git add'
|
||||||
|
alias gaa='git add -A'
|
||||||
|
alias gd='git diff'
|
||||||
|
alias gds='git diff --staged'
|
||||||
|
alias gsh='git stash'
|
||||||
|
alias gsp='git stash pop'
|
||||||
|
alias gr='git restore'
|
||||||
|
alias grs='git restore --staged'
|
||||||
|
alias gclean='git clean -fd'
|
||||||
|
|
||||||
|
# Enhanced Git functions
|
||||||
|
clone() {
|
||||||
|
if [[ $# -eq 1 ]]; then
|
||||||
|
git clone "$1"
|
||||||
|
cd "$(basename "$1" .git)" 2>/dev/null || cd "$(basename "$1")"
|
||||||
|
else
|
||||||
|
git clone "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Safe rm with trash (when available)
|
||||||
|
if [[ "$_OS_TYPE" != MINGW* && "$_OS_TYPE" != CYGWIN* ]] && command -v trash &>/dev/null; then
|
||||||
|
alias rm='trash'
|
||||||
|
alias rrm='/bin/rm'
|
||||||
|
else
|
||||||
|
alias rrm='/bin/rm'
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Enhanced file operations with safety
|
||||||
|
alias cp='cp -i'
|
||||||
|
alias mv='mv -i'
|
||||||
|
alias ln='ln -i'
|
||||||
|
|
||||||
|
# System utilities
|
||||||
|
alias df='df -h'
|
||||||
|
alias du='du -h'
|
||||||
|
alias dus='du -sh'
|
||||||
|
alias free='free -h'
|
||||||
|
alias ps='ps aux'
|
||||||
|
alias psg='ps aux | grep'
|
||||||
|
alias top='htop' 2>/dev/null || alias top='top'
|
||||||
|
|
||||||
|
# Network utilities
|
||||||
|
alias ping='ping -c 4'
|
||||||
|
alias ports='netstat -tuln' 2>/dev/null || alias ports='netstat -an'
|
||||||
|
alias ipinfo='curl ipinfo.io'
|
||||||
|
|
||||||
|
# Weather functions
|
||||||
|
alias wt='curl wttr.in'
|
||||||
|
wti() {
|
||||||
|
[[ -z "$1" ]] && { echo "Usage: wti <location>"; return 1 }
|
||||||
|
curl "wttr.in/$1?format=3" 2>/dev/null || { echo "Failed to fetch weather for $1"; return 1 }
|
||||||
|
}
|
||||||
|
|
||||||
|
# Modern archive extraction
|
||||||
|
extract() {
|
||||||
|
[[ ! -f "$1" ]] && { echo "'$1' is not a valid file"; return 1 }
|
||||||
|
case "$1" in
|
||||||
|
*.tar.bz2) tar xjf "$1" ;;
|
||||||
|
*.tar.gz) tar xzf "$1" ;;
|
||||||
|
*.bz2) bunzip2 "$1" ;;
|
||||||
|
*.rar) unrar x "$1" ;;
|
||||||
|
*.gz) gunzip "$1" ;;
|
||||||
|
*.tar) tar xf "$1" ;;
|
||||||
|
*.tbz2) tar xjf "$1" ;;
|
||||||
|
*.tgz) tar xzf "$1" ;;
|
||||||
|
*.zip) unzip "$1" ;;
|
||||||
|
*.Z) uncompress "$1" ;;
|
||||||
|
*.7z) 7z x "$1" ;;
|
||||||
|
*) echo "'$1' cannot be extracted via extract()" ;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,127 @@
|
||||||
# Homebrew setup and completions
|
#!/usr/bin/env zsh
|
||||||
if command -v brew &>/dev/null; then
|
# Modern Zsh completion configuration
|
||||||
export HOMEBREW_PREFIX="$(brew --prefix)"
|
|
||||||
eval "$("${HOMEBREW_PREFIX}/bin/brew" shellenv)"
|
|
||||||
|
|
||||||
# Add site-functions to FPATH for completions
|
# Cache directories for performance
|
||||||
FPATH="${HOMEBREW_PREFIX}/share/zsh/site-functions:${FPATH}"
|
typeset -g cache_dir="${XDG_CACHE_HOME:-$HOME/.cache}/zsh"
|
||||||
|
typeset -g compdump="${ZDOTDIR:-$HOME}/.zsh/.zcompdump-${ZSH_VERSION}"
|
||||||
|
|
||||||
|
# Create cache directory if needed
|
||||||
|
if [[ ! -d "$cache_dir" ]]; then
|
||||||
|
mkdir -p "$cache_dir" 2>/dev/null || {
|
||||||
|
cache_dir="/tmp/zsh-cache-$USER"
|
||||||
|
mkdir -p "$cache_dir" 2>/dev/null
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# zcompdump cache
|
# Add custom completion directories
|
||||||
mkdir -p "$HOME/.zsh/cache"
|
if [[ -z "$_COMPLETION_PATHS_CACHED" ]]; then
|
||||||
ZSH_COMPDUMP="${ZDOTDIR:-$HOME}/.zcompdump"
|
[[ -d "${ZDOTDIR:-$HOME}/.zsh/completions" ]] && fpath=("${ZDOTDIR:-$HOME}/.zsh/completions" $fpath)
|
||||||
zstyle ':completion::complete:*' use-cache on
|
export _COMPLETION_PATHS_CACHED=1
|
||||||
zstyle ':completion::complete:*' cache-path "$HOME/.zsh/cache"
|
|
||||||
|
|
||||||
# Load compinit safely
|
|
||||||
if [[ -z "$_compinit_done" ]]; then
|
|
||||||
autoload -Uz compinit
|
|
||||||
compinit -C -d "$ZSH_COMPDUMP"
|
|
||||||
_compinit_done=1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Homebrew completion paths
|
||||||
|
if [[ -d "/opt/homebrew/share/zsh/site-functions" ]] || [[ "${HOMEBREW_PREFIX-}" == "/opt/homebrew" ]]; then
|
||||||
|
fpath=(${fpath:#/usr/local/share/zsh/site-functions})
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${HOMEBREW_PREFIX-}" && -d "$HOMEBREW_PREFIX/share/zsh/site-functions" ]]; then
|
||||||
|
fpath=("$HOMEBREW_PREFIX/share/zsh/site-functions" $fpath)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Silence completion warnings
|
||||||
|
ZSH_DISABLE_COMPFIX=true
|
||||||
|
|
||||||
|
# Initialize completion system
|
||||||
|
autoload -Uz compinit
|
||||||
|
|
||||||
|
# Ensure compdump parent directory exists
|
||||||
|
if [[ -n "$compdump" ]]; then
|
||||||
|
mkdir -p "${compdump:h}" 2>/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Initialize completion using cached compdump; -C skips expensive security checks
|
||||||
|
compinit -i -C -d "$compdump"
|
||||||
|
|
||||||
|
# Background compilation for performance
|
||||||
|
{
|
||||||
|
[[ -s "$compdump" && ( ! -s "${compdump}.zwc" || "$compdump" -nt "${compdump}.zwc" ) ]] && \
|
||||||
|
zcompile "$compdump" 2>/dev/null
|
||||||
|
} &!
|
||||||
|
|
||||||
|
# Modern completion styles
|
||||||
|
zstyle ':completion:*' menu select # Interactive menu
|
||||||
|
zstyle ':completion:*' group-name '' # Group by type
|
||||||
|
zstyle ':completion:*' verbose no # Detailed descriptions
|
||||||
|
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}" # Use LS_COLORS
|
||||||
|
zstyle ':completion:*' use-cache on # Enable caching
|
||||||
|
zstyle ':completion:*' cache-path "$cache_dir" # Cache location
|
||||||
|
zstyle ':completion:*' accept-exact '*(N)' # Accept exact matches
|
||||||
|
zstyle ':completion:*' use-compctl false # Disable deprecated system
|
||||||
|
zstyle ':completion:*' max-errors 2 # Error tolerance
|
||||||
|
zstyle ':completion:*' accept-exact-dirs true # Directory completion
|
||||||
|
zstyle ':completion:*' recent-dirs insert both # Recent directories
|
||||||
|
zstyle ':completion:*' squeeze-slashes true # Multiple slashes as one
|
||||||
|
zstyle ':completion:*' special-dirs true # Include . and ..
|
||||||
|
zstyle ':completion:*' file-patterns '%p(^-/):globbed-files *(-/):directories *:all-files'
|
||||||
|
|
||||||
|
# Case-insensitive, partial-word, substring completion
|
||||||
|
zstyle ':completion:*' matcher-list \
|
||||||
|
'm:{a-zA-Z}={A-Za-z}' \
|
||||||
|
'r:|[._-]=* r:|=*' \
|
||||||
|
'l:|=* r:|=*'
|
||||||
|
|
||||||
|
# fzf-tab configuration
|
||||||
|
zstyle ':fzf-tab:*' fzf-command fzf
|
||||||
|
zstyle ':fzf-tab:*' switch-group ',' '.'
|
||||||
|
zstyle ':fzf-tab:*' continuous-trigger '/'
|
||||||
|
zstyle ':fzf-tab:*' fzf-bindings 'tab:accept'
|
||||||
|
zstyle ':fzf-tab:*' accept-line enter
|
||||||
|
|
||||||
|
# Disable default group colors that show format codes
|
||||||
|
zstyle ':fzf-tab:*' show-group full
|
||||||
|
zstyle ':fzf-tab:*' prefix ''
|
||||||
|
|
||||||
|
# Preview for files and directories
|
||||||
|
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'ls -1 --color=always $realpath 2>/dev/null'
|
||||||
|
zstyle ':fzf-tab:complete:ls:*' fzf-preview 'ls -1 --color=always $realpath 2>/dev/null'
|
||||||
|
|
||||||
|
# Better fzf flags
|
||||||
|
zstyle ':fzf-tab:*' fzf-flags --height=50% --layout=reverse --info=inline
|
||||||
|
|
||||||
|
# Process completion for kill commands
|
||||||
|
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm -w -w"
|
||||||
|
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#) ([0-9a-z-]#)*=01;34=0=01'
|
||||||
|
zstyle ':completion:*:*:kill:*' menu yes select
|
||||||
|
zstyle ':completion:*:*:kill:*' force-list always
|
||||||
|
zstyle ':completion:*:*:kill:*' insert-ids single
|
||||||
|
|
||||||
|
# Filter out system users and unwanted patterns
|
||||||
|
zstyle ':completion:*:*:*:users' ignored-patterns \
|
||||||
|
adm amanda apache at avahi avahi-autoipd beaglidx bin cacti canna \
|
||||||
|
clamav daemon dbus distcache dnsmasq dovecot fax ftp games gdm \
|
||||||
|
gkrellmd gopher hacluster haldaemon halt hsqldb ident junkbust kdm \
|
||||||
|
ldap lp mail mailman mailnull man messagebus mldonkey mysql nagios \
|
||||||
|
named netdump news nfsnobody nobody nscd ntp nut nx obsrun openvpn \
|
||||||
|
operator pcap polkitd postfix postgres privoxy pulse pvm quagga radvd \
|
||||||
|
rpc rpcuser rpm rtkit scard shutdown squid sshd statd svn sync tftp \
|
||||||
|
usbmux uucp vcsa wwwrun xfs '_*'
|
||||||
|
|
||||||
|
zstyle ':completion:*:complete:-command-:*' ignored-patterns '*\~'
|
||||||
|
zstyle ':completion:*:functions' ignored-patterns '_*'
|
||||||
|
zstyle ':completion:*:parameters' ignored-patterns 'ZINIT*'
|
||||||
|
zstyle ':completion:*:variables' ignored-patterns 'ZINIT*'
|
||||||
|
|
||||||
|
# Disable hostname completion and configure manual pages
|
||||||
|
zstyle ':completion:*:hosts' hosts off
|
||||||
|
zstyle ':completion:*:manuals' separate-sections true
|
||||||
|
zstyle ':completion:*:manuals.(^1*)' insert-sections true
|
||||||
|
zstyle ':completion:*:cd:*' ignore-parents parent pwd
|
||||||
|
|
||||||
|
# Use faster process listing commands
|
||||||
|
zstyle ':completion:*:*:kill:*:processes' command 'ps -eo pid,user,comm --no-headers'
|
||||||
|
zstyle ':completion:*:processes' command 'ps -eo pid,user,comm --no-headers'
|
||||||
|
|
||||||
|
# Include hidden files in completion
|
||||||
|
setopt globdots
|
||||||
|
_comp_options+=(globdots)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,131 @@
|
||||||
# Starship prompt
|
#!/usr/bin/env zsh
|
||||||
export STARSHIP_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/starship.toml"
|
# Modern external tool integrations with optimized lazy loading
|
||||||
eval "$(starship init zsh)"
|
|
||||||
|
|
||||||
# zoxide init
|
# Vanilla mode for dumb terminals (IDEs, Windsurf, etc.)
|
||||||
if command -v eza &>/dev/null; then
|
if [ "$TERM" = "dumb" ]; then
|
||||||
export _ZO_FZF_OPTS="--preview='eza -a --color=always {} | head -30' --preview-window=down:30%"
|
# Clean, standard prompt for IDE environments
|
||||||
else
|
export PS1="%n@%m %1~ %# "
|
||||||
export _ZO_FZF_OPTS="--preview='ls -la {} | head -30' --preview-window=down:30%"
|
# Disable most shell features for maximum compatibility
|
||||||
|
unsetopt prompt_cr prompt_sp prompt_subst
|
||||||
|
setopt no_prompt_cr no_prompt_sp no_prompt_subst
|
||||||
|
# Skip loading external tools in vanilla mode
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
eval "$(zoxide init --cmd cd zsh)"
|
|
||||||
|
|
||||||
# pyenv
|
# direnv (must be before starship)
|
||||||
if command -v pyenv 1>/dev/null 2>&1; then
|
if command -v direnv &>/dev/null; then
|
||||||
|
eval "$(direnv hook zsh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# starship
|
||||||
|
if command -v starship &>/dev/null; then
|
||||||
|
export STARSHIP_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}/starship.toml"
|
||||||
|
eval "$(starship init zsh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Lazy load zoxide for smart directory navigation
|
||||||
|
if command -v zoxide &>/dev/null; then
|
||||||
|
eval "$(zoxide init --cmd cd zsh)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Lazy load pyenv (Python version management)
|
||||||
|
if command -v pyenv &>/dev/null; then
|
||||||
export PYENV_ROOT="$HOME/.pyenv"
|
export PYENV_ROOT="$HOME/.pyenv"
|
||||||
[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"
|
pyenv() {
|
||||||
eval "$(pyenv init -)"
|
unset -f pyenv
|
||||||
|
eval "$(command pyenv init -)"
|
||||||
|
pyenv "$@"
|
||||||
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# direnv
|
[[ -o interactive ]] || return 0
|
||||||
command -v direnv &>/dev/null && eval "$(direnv hook zsh)"
|
|
||||||
|
|
||||||
# conda (OFFICIAL – preferred over manual conda.sh sourcing)
|
__safe_unset() {
|
||||||
if [ -f "/opt/homebrew/Caskroom/miniforge/base/bin/conda" ]; then
|
for f in "$@"; do
|
||||||
eval "$(/opt/homebrew/Caskroom/miniforge/base/bin/conda shell.zsh hook)"
|
whence -w "$f" &>/dev/null && unset -f "$f"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# Manually assign the conda completion function to mamba
|
if command -v micromamba &>/dev/null; then
|
||||||
if type mamba &>/dev/null && type _conda &>/dev/null; then
|
micromamba() {
|
||||||
compdef _conda mamba
|
__safe_unset micromamba conda mamba
|
||||||
fi
|
eval "$(command micromamba shell hook -s zsh)" || return 1
|
||||||
|
micromamba "$@"
|
||||||
|
}
|
||||||
|
elif command -v mamba &>/dev/null; then
|
||||||
|
mamba() {
|
||||||
|
__safe_unset mamba conda
|
||||||
|
eval "$(command mamba shell hook --shell zsh)" || return 1
|
||||||
|
mamba "$@"
|
||||||
|
}
|
||||||
|
|
||||||
|
# conda is optional fallback
|
||||||
|
if command -v conda &>/dev/null; then
|
||||||
|
conda() {
|
||||||
|
__safe_unset conda mamba
|
||||||
|
eval "$(command conda shell.zsh hook)" || return 1
|
||||||
|
conda "$@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
elif command -v conda &>/dev/null; then
|
||||||
|
conda() {
|
||||||
|
__safe_unset conda
|
||||||
|
eval "$(command conda shell.zsh hook)" || return 1
|
||||||
|
conda "$@"
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Node.js environment setup
|
||||||
|
if command -v node &>/dev/null; then
|
||||||
|
typeset -g node_path_cache="${XDG_CACHE_HOME:-$HOME/.cache}/zsh/node_path"
|
||||||
|
if [[ -r "$node_path_cache" ]]; then
|
||||||
|
export NODE_PATH="$(<"$node_path_cache")"
|
||||||
|
else
|
||||||
|
{
|
||||||
|
local npm_prefix
|
||||||
|
npm_prefix="$(npm config get prefix 2>/dev/null)" || return 0
|
||||||
|
mkdir -p "${node_path_cache:h}" 2>/dev/null
|
||||||
|
print -r -- "${npm_prefix}/lib/node_modules" >| "$node_path_cache"
|
||||||
|
} &!
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Modern Rust toolchain (if present)
|
||||||
|
if command -v rustc &>/dev/null; then
|
||||||
|
export CARGO_HOME="${CARGO_HOME:-$HOME/.cargo}"
|
||||||
|
path=("$CARGO_HOME/bin" $path)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Go environment (modern setup)
|
||||||
|
if command -v go &>/dev/null; then
|
||||||
|
export GOPATH="${GOPATH:-$HOME/.go}"
|
||||||
|
path=("$GOPATH/bin" $path)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Modern Ruby environment (if present)
|
||||||
|
if command -v ruby &>/dev/null && command -v gem &>/dev/null; then
|
||||||
|
export GEM_HOME="${GEM_HOME:-$HOME/.gem}"
|
||||||
|
path=("$GEM_HOME/bin" $path)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Modern Java environment (if present)
|
||||||
|
if command -v java &>/dev/null; then
|
||||||
|
export JAVA_HOME="${JAVA_HOME:-$(/usr/libexec/java_home 2>/dev/null)}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Modern development environment variables
|
||||||
|
export EDITOR="${EDITOR:-nvim}"
|
||||||
|
export BROWSER="${BROWSER:-open}"
|
||||||
|
export PAGER="${PAGER:-less -i -N -S -R}"
|
||||||
|
|
||||||
|
# Modern application-specific settings
|
||||||
|
if command -v fzf &>/dev/null; then
|
||||||
|
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border --inline-info"
|
||||||
|
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --exclude .git"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Modern terminal integration
|
||||||
|
if [[ -n "$TMUX" ]]; then
|
||||||
|
export TERM="xterm-256color-italic"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1,78 @@
|
||||||
# ~/.config/zsh/plugins.zsh
|
#!/usr/bin/env zsh
|
||||||
|
# Modern Zinit plugin manager configuration
|
||||||
|
|
||||||
# Zinit setup
|
# Zinit installation and setup
|
||||||
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
|
local zinit_dir="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
|
||||||
[[ ! -d "$ZINIT_HOME" ]] && git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME"
|
|
||||||
source "${ZINIT_HOME}/zinit.zsh"
|
|
||||||
|
|
||||||
# Core plugins
|
# Install Zinit if not present
|
||||||
zinit light zsh-users/zsh-completions
|
if [[ ! -d "$zinit_dir" ]]; then
|
||||||
|
mkdir -p "$zinit_dir" 2>/dev/null || {
|
||||||
|
print -P "%F{red}Error: Cannot create zinit directory%f" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
git clone --depth 1 https://github.com/zdharma-continuum/zinit.git "$zinit_dir" 2>/dev/null || {
|
||||||
|
print -P "%F{red}Error: Failed to clone zinit%f" >&2
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
# Ollama CLI completion
|
# Load Zinit
|
||||||
zinit ice as"completion"
|
if [[ -f "$zinit_dir/zinit.zsh" ]]; then
|
||||||
zinit snippet https://raw.githubusercontent.com/Katrovsky/zsh-ollama-completion/main/_ollama
|
source "$zinit_dir/zinit.zsh"
|
||||||
|
autoload -Uz _zinit
|
||||||
|
(( ${+_comps} )) && _comps[zinit]=_zinit
|
||||||
|
else
|
||||||
|
print -P "%F{red}Error: Zinit not found%f" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Syntax highlighting
|
# Modern plugin loading with optimized performance
|
||||||
zinit ice wait lucid atinit"ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern)"
|
|
||||||
zinit load zsh-users/zsh-syntax-highlighting
|
|
||||||
|
|
||||||
# Autosuggestions
|
# Essential plugins - loaded immediately
|
||||||
zinit ice wait lucid atload"zle-line-init() { zle autosuggest-enable }; zle -N zle-line-init"
|
zinit wait'0' lucid for \
|
||||||
zinit load zsh-users/zsh-autosuggestions
|
zsh-users/zsh-autosuggestions
|
||||||
|
|
||||||
# History search
|
zinit wait'1' lucid atload'
|
||||||
zinit light zsh-users/zsh-history-substring-search
|
bindkey "$terminfo[kcuu1]" history-search-multi-word
|
||||||
zinit load zdharma-continuum/history-search-multi-word
|
bindkey "$terminfo[kcud1]" history-search-multi-word
|
||||||
|
' for \
|
||||||
|
zdharma-continuum/history-search-multi-word
|
||||||
|
|
||||||
# FZF and extras
|
# FZF integration
|
||||||
zinit ice from"gh-r" as"program" pick"bin/fzf"
|
zinit wait'2' lucid from"gh-r" as"program" pick"bin/fzf" for \
|
||||||
zinit light junegunn/fzf-bin
|
junegunn/fzf-bin
|
||||||
zinit light junegunn/fzf-git.sh
|
|
||||||
|
|
||||||
zinit ice wait lucid blockf
|
zinit wait'2a' lucid for \
|
||||||
zinit load Aloxaf/fzf-tab
|
junegunn/fzf-git.sh
|
||||||
|
|
||||||
zinit ice from"gh-r" as"program" pick"bin/zoxide"
|
zinit wait'2b' lucid for \
|
||||||
zinit load ajeetdsouza/zoxide
|
Aloxaf/fzf-tab
|
||||||
|
|
||||||
# Update alias
|
zinit wait'0' lucid for \
|
||||||
|
zdharma-continuum/fast-syntax-highlighting
|
||||||
|
|
||||||
|
|
||||||
|
# Modern terminal keybindings
|
||||||
|
if [[ "$TERM_PROGRAM" == "vscode" || "$TERM_PROGRAM" == "windsurf" ]]; then
|
||||||
|
# Simplified bindings for IDE terminals
|
||||||
|
bindkey '^[[A' history-search-backward
|
||||||
|
bindkey '^[[B' history-search-forward
|
||||||
|
bindkey '^?' backward-delete-char
|
||||||
|
bindkey '^W' backward-kill-word
|
||||||
|
else
|
||||||
|
# Full terminal application mode
|
||||||
|
[[ -n "$terminfo[kcuf1]" ]] && bindkey "$terminfo[kcuf1]" forward-char
|
||||||
|
[[ -n "$terminfo[kcub1]" ]] && bindkey "$terminfo[kcub1]" backward-char
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Zinit management aliases
|
||||||
alias zupdate='zinit update --all'
|
alias zupdate='zinit update --all'
|
||||||
|
alias zreport='zinit report'
|
||||||
|
|
||||||
|
# Plugin management helper functions
|
||||||
|
zls() { zinit list --installed }
|
||||||
|
zreload() {
|
||||||
|
zinit reload
|
||||||
|
print -P "%F{green}Zsh configuration reloaded%f"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
54
zsh/.fzf.zsh
54
zsh/.fzf.zsh
|
|
@ -1,28 +1,44 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
# FZF configuration
|
||||||
|
|
||||||
# Indicate the shell explicitly
|
# Skip if already loaded
|
||||||
export FZF_SHELL="zsh"
|
[[ -n "$_FZF_LOADED" ]] && return 0
|
||||||
|
|
||||||
# Ensure fzf is installed and get its path
|
# Check if FZF is available
|
||||||
if command -v fzf >/dev/null; then
|
if ! command -v fzf &>/dev/null; then
|
||||||
export FZF_PATH="$(dirname "$(command -v fzf)")"
|
return 0
|
||||||
else
|
|
||||||
export FZF_PATH=""
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load fzf key bindings and completion for zsh
|
# Configure for VSCode/Windsurf integrated terminals
|
||||||
if command -v fzf >/dev/null; then
|
if [[ "$TERM_PROGRAM" == "vscode" || "$TERM_PROGRAM" == "windsurf" ]]; then
|
||||||
[ -f "$FZF_PATH/key-bindings.zsh" ] && . "$FZF_PATH/key-bindings.zsh"]
|
export FZF_DEFAULT_OPTS="--height 40% --reverse --border"
|
||||||
[ -f "$FZF_PATH/completion.zsh" ] && . "$FZF_PATH/completion.zsh"]
|
export _FZF_LOADED=1
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load fzf theme if available
|
# Configure FZF options for regular terminals
|
||||||
FZF_THEME_SCRIPT="$HOME/.local/bin/scripts/fzf_theme.sh"
|
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border --cycle"
|
||||||
if [[ -f "$FZF_THEME_SCRIPT" ]]; then
|
|
||||||
# If theme script is available, use it and add the default fzf options
|
# Use fd for faster file searching if available
|
||||||
export FZF_DEFAULT_OPTS="$($FZF_THEME_SCRIPT) --height 40% --layout=reverse --border"
|
if command -v fd &>/dev/null; then
|
||||||
else
|
export FZF_DEFAULT_COMMAND='fd --type f --hidden --follow --exclude .git'
|
||||||
# Set default options for fzf without any theme, with preview enabled for general use
|
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
|
||||||
export FZF_DEFAULT_OPTS="--height 40% --layout=reverse --border"
|
export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude .git'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Load FZF key bindings and completion
|
||||||
|
if [[ -n "${HOMEBREW_PREFIX}" && -d "${HOMEBREW_PREFIX}/opt/fzf/shell" ]]; then
|
||||||
|
source "${HOMEBREW_PREFIX}/opt/fzf/shell/key-bindings.zsh" 2>/dev/null
|
||||||
|
source "${HOMEBREW_PREFIX}/opt/fzf/shell/completion.zsh" 2>/dev/null
|
||||||
|
elif FZF_PATH="$(dirname "$(command -v fzf)" 2>/dev/null)"; then
|
||||||
|
[[ -f "$FZF_PATH/key-bindings.zsh" ]] && source "$FZF_PATH/key-bindings.zsh"
|
||||||
|
[[ -f "$FZF_PATH/completion.zsh" ]] && source "$FZF_PATH/completion.zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Apply custom theme if available
|
||||||
|
if [[ -f "$HOME/.local/bin/scripts/fzf_theme.sh" ]]; then
|
||||||
|
FZF_THEME="$($HOME/.local/bin/scripts/fzf_theme.sh)"
|
||||||
|
export FZF_DEFAULT_OPTS="$FZF_THEME $FZF_DEFAULT_OPTS"
|
||||||
|
fi
|
||||||
|
|
||||||
|
export _FZF_LOADED=1
|
||||||
|
|
@ -1,37 +1,10 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
# ~/.zprofile - Login shell configuration (runs once per login)
|
||||||
|
|
||||||
# ── Brew shellenv ───────────────────────────────────────
|
# Homebrew initialization is handled in .zshenv for VSCode/IDE compatibility
|
||||||
if command -v brew &>/dev/null; then
|
# This file is for login-specific configuration only
|
||||||
export PATH="/opt/homebrew/bin:${PATH}"
|
|
||||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Add Homebrew curl to PATH if installed ─────────────
|
|
||||||
if command -v brew &>/dev/null && brew list curl &>/dev/null; then
|
|
||||||
CURL_PATH="$(brew --prefix curl)/bin"
|
|
||||||
[[ ":$PATH:" != *":$CURL_PATH:"* ]] && export PATH="$CURL_PATH:$PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Add FZF path to PATH ───────────────────────────────
|
|
||||||
if command -v fzf &>/dev/null; then
|
|
||||||
if command -v brew &>/dev/null; then
|
|
||||||
FZF_PATH="$(brew --prefix fzf)/bin"
|
|
||||||
else
|
|
||||||
FZF_PATH="$(dirname "$(command -v fzf)")"
|
|
||||||
fi
|
|
||||||
[[ ":$PATH:" != *":$FZF_PATH:"* ]] && export PATH="$FZF_PATH:$PATH"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ── Add TeX to PATH (macOS specific) ───────────────────
|
|
||||||
[[ -d "/Library/TeX/texbin" ]] && export PATH="/Library/TeX/texbin:$PATH"
|
|
||||||
|
|
||||||
# ── Zsh completion fpath for brew and other packages ──
|
|
||||||
# Add Homebrew’s zsh completions if they exist
|
|
||||||
BREW_ZSH_FUNCTIONS="$(brew --prefix 2>/dev/null)/share/zsh/site-functions"
|
|
||||||
if [[ -d "$BREW_ZSH_FUNCTIONS" ]]; then
|
|
||||||
fpath=("$BREW_ZSH_FUNCTIONS" $fpath)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Optional: Add your own completions directory
|
|
||||||
[[ -d "$HOME/.zsh/site-functions" ]] && fpath=("$HOME/.zsh/site-functions" $fpath)
|
|
||||||
|
|
||||||
|
# Add custom completion directories to fpath
|
||||||
|
# Uncomment the directory that exists on your system:
|
||||||
|
# [[ -d "$HOME/.zsh/site-functions" ]] && fpath=("$HOME/.zsh/site-functions" $fpath)
|
||||||
|
# [[ -d "$HOME/.zsh/completions" ]] && fpath=("$HOME/.zsh/completions" $fpath)
|
||||||
133
zsh/.zshenv
133
zsh/.zshenv
|
|
@ -1,93 +1,82 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
# ~/.zshenv - Environment variables and PATH (loaded for all shells)
|
||||||
|
|
||||||
# ------------------ Environment Setup ------------------
|
# XDG base directory specification
|
||||||
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||||
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
export XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
|
||||||
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
export XDG_DATA_HOME="${XDG_DATA_HOME:-$HOME/.local/share}"
|
||||||
|
|
||||||
|
# Default programs
|
||||||
export PAGER="less -i -N -S -R"
|
export PAGER="less -i -N -S -R"
|
||||||
export EDITOR="nvim"
|
export EDITOR="nvim"
|
||||||
export BROWSER="/Applications/Zen.app/Contents/MacOS/zen"
|
|
||||||
|
|
||||||
# ------------------ Helper Functions ------------------
|
# Ensure PATH entries are unique (use zsh's path array)
|
||||||
|
typeset -U path
|
||||||
|
|
||||||
|
# Helper function to safely add directories to PATH
|
||||||
safe_path_add() {
|
safe_path_add() {
|
||||||
[[ -d "$1" && ":$PATH:" != *":$1:"* ]] && export PATH="$1:$PATH"
|
[[ -d "$1" ]] || return 0
|
||||||
|
(( ${path[(Ie)$1]} )) || path=("$1" $path)
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------ Platform Detection ------------------
|
# Cache platform detection to avoid repeated uname calls
|
||||||
OS_TYPE="$(uname -s)"
|
export _OS_TYPE="${_OS_TYPE:-$(uname -s)}"
|
||||||
ARCH="$(uname -m)"
|
export _ARCH="${_ARCH:-$(uname -m)}"
|
||||||
|
|
||||||
# ------------------ macOS Setup ------------------
|
# Homebrew prefix (cheap detection; no brew invocation)
|
||||||
# macOS Homebrew and Toolchain Setup
|
if [[ "$_OS_TYPE" == "Darwin" ]]; then
|
||||||
if [[ "$OS_TYPE" == "Darwin" ]]; then
|
if [[ -x "/opt/homebrew/bin/brew" ]]; then
|
||||||
if [[ "$ARCH" == "arm64" ]]; then
|
export HOMEBREW_PREFIX="/opt/homebrew"
|
||||||
export HOMEBREW_PREFIX="/opt/homebrew"
|
elif [[ -x "/usr/local/bin/brew" ]]; then
|
||||||
else
|
export HOMEBREW_PREFIX="/usr/local"
|
||||||
export HOMEBREW_PREFIX="/usr/local"
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
safe_path_add "$HOMEBREW_PREFIX/bin"
|
# Homebrew shellenv (Option A: interactive shells only)
|
||||||
safe_path_add "$HOMEBREW_PREFIX/sbin"
|
if [[ -o interactive ]] && [[ -z "$_HOMEBREW_INITIALIZED" ]]; then
|
||||||
|
if [[ -n "${HOMEBREW_PREFIX-}" && -x "$HOMEBREW_PREFIX/bin/brew" ]]; then
|
||||||
|
eval "$("$HOMEBREW_PREFIX/bin/brew" shellenv)"
|
||||||
|
elif command -v brew &>/dev/null; then
|
||||||
|
eval "$(brew shellenv)"
|
||||||
|
fi
|
||||||
|
export _HOMEBREW_INITIALIZED=1
|
||||||
|
fi
|
||||||
|
|
||||||
for dir in \
|
# Set default browser based on platform
|
||||||
"$HOMEBREW_PREFIX/opt/coreutils/libexec/gnubin" \
|
if [[ -z "$BROWSER" ]]; then
|
||||||
"$HOMEBREW_PREFIX/opt/openssl@1.1/bin" \
|
if [[ "$_OS_TYPE" == "Darwin" ]]; then
|
||||||
"$HOMEBREW_PREFIX/opt/llvm/bin" \
|
if [[ -f "/Applications/Zen.app/Contents/MacOS/zen" ]]; then
|
||||||
"/Library/TeX/texbin" \
|
export BROWSER="/Applications/Zen.app/Contents/MacOS/zen"
|
||||||
"$HOMEBREW_PREFIX/opt/rustup/bin"; do
|
elif [[ -f "/Applications/Safari.app/Contents/MacOS/Safari" ]]; then
|
||||||
safe_path_add "$dir"
|
export BROWSER="/Applications/Safari.app/Contents/MacOS/Safari"
|
||||||
done
|
fi
|
||||||
# ------------------ Linux Setup ------------------
|
else
|
||||||
elif [[ "$OS_TYPE" == "Linux" ]]; then
|
export BROWSER="$(command -v firefox || command -v google-chrome || command -v chromium)"
|
||||||
safe_path_add "$HOME/.local/bin"
|
fi
|
||||||
safe_path_add "$HOME/.cargo/bin"
|
fi
|
||||||
safe_path_add "$HOME/.local/share/flatpak/exports/bin"
|
|
||||||
safe_path_add "/var/lib/flatpak/exports/bin"
|
|
||||||
[[ -d "/nix" ]] && safe_path_add "/nix/var/nix/profiles/default/bin"
|
|
||||||
|
|
||||||
# ------------------ WSL Detection ------------------
|
# Development tool paths
|
||||||
if grep -qEi "microsoft|wsl" /proc/version &>/dev/null; then
|
export PYENV_ROOT="${PYENV_ROOT:-$HOME/.pyenv}"
|
||||||
export IS_WSL=1
|
export GOPATH="${GOPATH:-$HOME/.go}"
|
||||||
export BROWSER="wslview"
|
|
||||||
export DISPLAY="${DISPLAY:-:0}"
|
|
||||||
export WSL_HOST="$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}')"
|
|
||||||
export NO_AT_BRIDGE=1
|
|
||||||
safe_path_add "/mnt/c/Windows/System32" # useful for calling Windows commands from WSL
|
|
||||||
fi
|
|
||||||
|
|
||||||
# ------------------ Remote Development Detection ------------------
|
# Add user and development tool directories to PATH
|
||||||
if [[ -n "$SSH_CONNECTION" ]]; then
|
if [[ -n "${HOMEBREW_PREFIX-}" ]]; then
|
||||||
|
safe_path_add "$HOMEBREW_PREFIX/bin"
|
||||||
|
safe_path_add "$HOMEBREW_PREFIX/sbin"
|
||||||
|
fi
|
||||||
|
safe_path_add "$HOME/.local/bin"
|
||||||
|
safe_path_add "$HOME/.local/bin/scripts"
|
||||||
|
safe_path_add "$HOME/.antigravity/antigravity/bin"
|
||||||
|
safe_path_add "/Applications/Windsurf.app/Contents/Resources/app/bin"
|
||||||
|
safe_path_add "$PYENV_ROOT/bin"
|
||||||
|
safe_path_add "$GOPATH/bin"
|
||||||
|
|
||||||
|
# Detect remote development environments
|
||||||
|
if [[ -n "$SSH_CONNECTION" ]]; then
|
||||||
export IS_REMOTE=1
|
export IS_REMOTE=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "$CODESPACES" ]] || [[ -d "/workspaces" ]]; then
|
if [[ -n "$CODESPACES" ]] || [[ -d "/workspaces" ]]; then
|
||||||
export IS_CODESPACES=1
|
export IS_CODESPACES=1
|
||||||
safe_path_add "/workspaces/bin"
|
safe_path_add "/workspaces/bin"
|
||||||
fi
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# ------------------ Common PATH ------------------
|
|
||||||
safe_path_add "$HOME/.local/bin/scripts"
|
|
||||||
|
|
||||||
# ------------------ Language Toolchains ------------------
|
|
||||||
|
|
||||||
# Python (pyenv)
|
|
||||||
export PYENV_ROOT="$HOME/.pyenv"
|
|
||||||
|
|
||||||
safe_path_add "$PYENV_ROOT/bin"
|
|
||||||
safe_path_add "$PYENV_ROOT/shims"
|
|
||||||
|
|
||||||
# Go
|
|
||||||
if command -v go &>/dev/null; then
|
|
||||||
export GOPATH="${GOPATH:-$HOME/.go}"
|
|
||||||
safe_path_add "$GOPATH/bin"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# NVM
|
|
||||||
if [[ -d "$HOME/.nvm" ]]; then
|
|
||||||
export NVM_DIR="$HOME/.nvm"
|
|
||||||
[[ -s "$NVM_DIR/nvm.sh" ]] && . "$NVM_DIR/nvm.sh"
|
|
||||||
[[ -s "$NVM_DIR/zsh_completion" ]] && . "$NVM_DIR/bash_completion"
|
|
||||||
fi
|
|
||||||
|
|
||||||
46
zsh/.zshrc
46
zsh/.zshrc
|
|
@ -1,20 +1,40 @@
|
||||||
#!/usr/bin/env zsh
|
#!/usr/bin/env zsh
|
||||||
|
# ~/.zshrc - Interactive shell configuration
|
||||||
|
|
||||||
# Optional profiling
|
# Vanilla mode for dumb terminals (IDEs, Windsurf, etc.)
|
||||||
[[ -n $ZSH_DEBUGRC ]] && zmodload zsh/zprof
|
if [ "$TERM" = "dumb" ]; then
|
||||||
|
# Keep IDE shells as vanilla as possible, but still set a simple prompt.
|
||||||
|
typeset -g zsh_config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
|
||||||
|
source "$zsh_config_dir/external.zsh"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
# Path cleanup
|
# Performance profiling (run with: ZSH_PROFILE=1 zsh)
|
||||||
typeset -U PATH
|
if [[ -n $ZSH_PROFILE ]]; then
|
||||||
|
zmodload zsh/zprof
|
||||||
|
fi
|
||||||
|
|
||||||
# Core config
|
# Ensure unique PATH entries
|
||||||
source ~/.config/zsh/completion.zsh
|
typeset -U PATH path cdpath fpath manpath
|
||||||
source ~/.config/zsh/plugins.zsh
|
|
||||||
source ~/.config/zsh/aliases.zsh
|
|
||||||
source ~/.config/zsh/external.zsh
|
|
||||||
|
|
||||||
# Editor for SSH
|
# Load configuration modules in optimized order
|
||||||
[[ -n ${SSH_CONNECTION} ]] && export EDITOR='vim'
|
typeset -g zsh_config_dir="${XDG_CONFIG_HOME:-$HOME/.config}/zsh"
|
||||||
|
source "$zsh_config_dir/external.zsh"
|
||||||
|
source "$zsh_config_dir/completion.zsh"
|
||||||
|
source "$zsh_config_dir/plugins.zsh"
|
||||||
|
source "$zsh_config_dir/aliases.zsh"
|
||||||
|
|
||||||
# Show zprof results if debugging
|
# FZF integration (load last for keybindings)
|
||||||
[[ -n $ZSH_DEBUGRC ]] && zprof
|
if [[ -f "$HOME/.fzf.zsh" ]]; then
|
||||||
|
source "$HOME/.fzf.zsh"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# SSH environment fallback
|
||||||
|
[[ -n "$SSH_CONNECTION" && -z "$EDITOR" ]] && export EDITOR='vim'
|
||||||
|
|
||||||
|
# Show profiling results
|
||||||
|
if [[ -n $ZSH_PROFILE ]]; then
|
||||||
|
zprof
|
||||||
|
fi
|
||||||
|
# Zoxide FZF theme colors (managed by theme-switcher)
|
||||||
|
export _ZO_FZF_OPTS="--height 40% --layout=reverse --border --preview-window=down:3:wrap --color=fg:#f8f8f2,bg:#2a2f3b,hl:#f92672,fg+:#f8f8f2,bg+:#49483e,hl+:#f92672,info:#a6e22e,prompt:#66d9ef,pointer:#f92672,marker:#a6e22e,spinner:#a6e22e,header:#66d9ef"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue