-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.zshrc
More file actions
181 lines (151 loc) · 5.44 KB
/
.zshrc
File metadata and controls
181 lines (151 loc) · 5.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# PATH management
typeset -U path # Keep unique entries
path=(
"/usr/local/bin"
"/usr/bin"
"/bin"
"/usr/sbin"
"/sbin"
"$HOME/.local/bin"
"$HOME/bin"
"$HOME/.local/share/nvim/mason/bin"
"$HOME/.config/scripts"
$path
)
export PATH
# ------------------------------------------------------------
# mise
# ------------------------------------------------------------
[[ -f /etc/os-release ]] && grep -q 'ubuntu' /etc/os-release && export MISE_ENV=ubuntu
if command -v mise >/dev/null 2>&1; then
eval "$(mise activate zsh)"
fi
# System-specific configs
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
# ------------------------------------------------------------
# Zsh Options & Environment Variables
# ------------------------------------------------------------
setopt autocd # Type directory name to cd
setopt auto_pushd # cd pushes old dir to stack
setopt pushd_ignore_dups # No duplicates in dir stack
setopt complete_in_word # Complete from cursor position
setopt glob_dots # Include dotfiles in globs
setopt no_beep # Disable beep
setopt interactive_comments # Allow comments in interactive shell
HISTSIZE=100000
HISTFILE=~/.zsh_history
SAVEHIST=$HISTSIZE
HISTTIMEFORMAT="%F %T "
setopt sharehistory # share across sessions
setopt appendhistory # append instead of overwrite
setopt hist_ignore_space # ignore commands starting with space
setopt hist_ignore_dups # ignore all duplicates
setopt hist_find_no_dups # ignore duplicates during search
setopt hist_reduce_blanks # remove extra blanks
setopt hist_save_no_dups # remove older duplicates when saving
# Remove slash, equals, and hyphen from WORDCHARS
WORDCHARS="${WORDCHARS//[\/=\-]/}"
# Basic environment
export EDITOR=nvim
export TERM=xterm-256color
export XDG_CONFIG_HOME="$HOME/.config"
# ------------------------------------------------------------
# Zinit
# ------------------------------------------------------------
ZINIT_HOME="${XDG_DATA_HOME:-${HOME}/.local/share}/zinit/zinit.git"
# Download Zinit, if it's not there yet
if [ ! -d "$ZINIT_HOME" ]; then
mkdir -p "$(dirname $ZINIT_HOME)"
git clone https://github.com/zdharma-continuum/zinit.git "$ZINIT_HOME" || { rm -rf "$ZINIT_HOME"; echo "Failed to clone zinit"; return 1; }
fi
source "${ZINIT_HOME}/zinit.zsh"
ZSH_AUTOSUGGEST_USE_ASYNC=true
ZSH_AUTOSUGGEST_STRATEGY=(history completion)
# --- Plugins ---
zinit ice wait lucid
zinit light agkozak/zsh-z # Fast directory jump
zinit ice wait lucid
zinit light zsh-users/zsh-completions # Completions
# Load these with wait for faster startup
zinit ice wait lucid
zinit light zsh-users/zsh-autosuggestions
zinit ice wait lucid
zinit light Aloxaf/fzf-tab # FZF tab completion
zinit ice wait lucid
zinit snippet OMZ::plugins/git/git.plugin.zsh
# Load syntax highlighting (deferred, should load after compdef plugins)
zinit ice wait lucid
zinit light zdharma-continuum/fast-syntax-highlighting
# Pure prompt
zinit ice compile'(pure|async).zsh' pick'async.zsh' src'pure.zsh'
zinit light sindresorhus/pure # Prompt
# Completion init (single compinit call)
[[ ! -d "$HOME/.zsh/cache" ]] && mkdir -p "$HOME/.zsh/cache"
autoload -Uz compinit
compinit -d "$HOME/.zsh/cache/zcompdump-${ZSH_VERSION}"
zinit cdreplay -q
# ------------------------------------------------------------
# Modular Configs
# ------------------------------------------------------------
for file in ~/.config/zsh/*.zsh(N); do
[[ -r "$file" ]] && source "$file"
done
# Completion styles
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'
zstyle ':completion:*' list-colors "${(s.:.)LS_COLORS}"
zstyle ':completion:*' menu select
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path "$HOME/.zsh/cache"
zstyle ':fzf-tab:complete:cd:*' fzf-preview 'eza -1 --color=always $realpath 2>/dev/null || ls -1 $realpath'
zstyle ':fzf-tab:*' fzf-flags --height=60%
# Lazy-load kubectl completion
if command -v kubectl >/dev/null 2>&1; then
kubectl() {
unfunction kubectl
source <(command kubectl completion zsh)
kubectl "$@"
}
fi
# Keybindings
bindkey -e
bindkey '^p' history-search-backward
bindkey '^n' history-search-forward
# ------------------------------------------------------------
# Aliases
# ------------------------------------------------------------
alias vi="nvim"
alias vim="nvim"
alias t="tmux attach || tmux"
#open btop if exists
if command -v btop >/dev/null 2>&1; then
alias top="btop"
fi
# ls/eza aliases
if command -v eza >/dev/null 2>&1; then
alias ls='eza --icons --group-directories-first'
alias ll='eza -lh --icons --group-directories-first'
alias la='eza -lah --icons --group-directories-first'
alias tree='eza --tree --icons'
else
alias ls='ls --color'
alias ll='ls -lh'
alias la='ls -lah'
fi
# Docker aliases
alias dps='docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"'
alias dcu='docker compose up -d'
alias dcd='docker compose down'
alias dcl='docker compose logs -f'
# Kubernetes aliases
alias k='kubectl'
alias kgp='kubectl get pods | fzf'
alias kgs='kubectl get svc | fzf'
alias kgd='kubectl get deployments | fzf'
alias kl='kubectl logs -f'
alias kpf='kubectl port-forward'
# Hash directories for quick movement
hash -d dotfiles="$HOME/dotfiles"
hash -d vaults="$HOME/.vaults"
# Conditional aliases
command -v lazydocker >/dev/null 2>&1 && alias ld="lazydocker"
command -v bat >/dev/null 2>&1 && alias cat='bat -pp'