Repository navigation
Expand file tree
/
Copy pathdot_zshrc
More file actions
204 lines (161 loc) · 4.88 KB
/
Copy pathdot_zshrc
File metadata and controls
204 lines (161 loc) · 4.88 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
#zmodload zsh/zprof
#
# Oh My ZSH config
#
export ZSH=$HOME/.oh-my-zsh
# Prompt is handled by starship (see ~/.config/starship.toml, initialized at
# the end of this file). Disable the oh-my-zsh theme so it doesn't fight it.
ZSH_THEME=""
#
# Completion plugin config
#
COMPLETION_WAITING_DOTS="true"
#
# TMUX plugin config
#
# enable autostart only if not running on i3
[ ! -z "$(pgrep '^i3$')" ] && ZSH_TMUX_AUTOSTART=false || ZSH_TMUX_AUTOSTART=true
export PATH="/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/local/games:/usr/games:$HOME/.cargo/bin:$HOME/.bin:$HOME/.scripts:$HOME/.local/bin:$PATH"
plugins=(aws git ssh-agent tmux kubectl docker history-substring-search zsh-autosuggestions zsh-syntax-highlighting)
SHOW_AWS_PROMPT=false
#
# User config
#
#
# Functions
#
keyadd() {
KEY_PREFIX='_key-'
ssh-add ~/.ssh/${KEY_PREFIX}${1}/id_rsa || ssh-add -L
}
osx() {
[ $(uname) = 'Darwin' ]
}
linux() {
[ $(uname) = 'Linux' ]
}
fixssh() {
for key in SSH_AUTH_SOCK SSH_CONNECTION SSH_CLIENT; do
if (tmux show-environment | grep "^${key}" > /dev/null); then
value=`tmux show-environment | grep "^${key}" | sed -e "s/^[A-Z_]*=//"`
export ${key}="${value}"
fi
done
}
rmtrailspaces() {
sed -i 's/[[:space:]]\+$//' $1
}
#
# Exports
#
source $ZSH/oh-my-zsh.sh
# neovim is provided by mise (see ~/.config/mise/config.toml)
export VIM_EXECUTABLE=$(which nvim)
# git identity lives in ~/.gitconfig (templated by chezmoi) — single source of truth
export EDITOR=$VIM_EXECUTABLE
# ripgrep config (replaces ack / ~/.ackrc)
export RIPGREP_CONFIG_PATH=$HOME/.ripgreprc
# revert ls quoting behaviour introduced in coreutils 8.25
export QUOTING_STYLE=literal
#
# Golang (toolchain managed by mise; keep custom GOPATH)
#
export GOPATH=$HOME/Development/golang
export PATH=$PATH:$GOPATH/bin
#
# Python (uv — replaces pyenv + virtualenvwrapper)
#
command -v uv >/dev/null && eval "$(uv generate-shell-completion zsh)"
#
# Google Cloud SDK
#
#source ~/opt/google-cloud-sdk/path.zsh.inc
#source ~/opt/google-cloud-sdk/completion.zsh.inc
#
# Aliases
#
alias mypublicip='wget http://ipinfo.io/ip -qO -'
alias vim=$VIM_EXECUTABLE
linux && alias pbcopy='xsel --clipboard --input'
linux && alias pbpaste='xsel --clipboard'
linux && alias vpnup='nmcli c up riccardo_teal --ask'
linux && alias vpndown='nmcli c down riccardo_teal'
# kubectl
alias k='kubectl'
alias kns='k get namespaces'
path+=~/.krew/bin
# Quick-open a file in the editor via fzf (replaces the old fasd `v`)
v() { local f; f=$(fzf) && [ -n "$f" ] && "$VIM_EXECUTABLE" "$f"; }
# grep through history
alias hg="history | grep"
# chezmoi
alias cm=chezmoi
#
# Completion - aws, ssh, ...
#
fpath+=~/.oh-my-zsh/custom/functions
autoload bashcompinit && bashcompinit
autoload -Uz compinit && compinit
osx && complete -C $(which aws_completer) aws
# ssh host completion
[ -r ~/.ssh/known_hosts ] && _ssh_hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[\|]*}%%\ *}%%,*}) || _ssh_hosts=()
[ -r /etc/hosts ] && : ${(A)_etc_hosts:=${(s: :)${(ps:\t:)${${(f)~~"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}} || _etc_hosts=()
hosts=(
"$_ssh_hosts[@]"
"$_etc_hosts[@]"
`hostname`
localhost
)
zstyle ':completion:*:hosts' hosts $hosts
# enable vim bindings
bindkey -v
export KEYTIMEOUT=1
bindkey "^I" expand-or-complete-with-dots #fix dot completion
# backward and forward history search
bindkey '^r' history-incremental-pattern-search-backward
bindkey '^t' history-incremental-pattern-search-forward
# Ctrl+space: print Git status
bindkey -s '^s' 'git status^M'
# Fix home end keys
bindkey "^a" beginning-of-line
bindkey "^e" end-of-line
bindkey "^u" backward-kill-line
bindkey "^k" kill-line
bindkey "^w" backward-kill-word
bindkey "^p" kill-word
bindkey "^[OH" beginning-of-line
bindkey "^[OF" end-of-line
bindkey "^[[1~" beginning-of-line
bindkey "^[[4~" end-of-line
bindkey "^[[3~" delete-char
#
# Nike
#
path+="$HOME/Development/gimme-aws-creds/bin"
#
# NPM
#
# https://stackoverflow.com/a/13021677
#
# NPM packages in homedir
NPM_PACKAGES="$HOME/.npm-packages"
# Tell our environment about user-installed node tools
PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your configuration
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
# Tell Node about these packages
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
#
# Tool initializations (order matters: starship sets PROMPT and goes last)
#
command -v mise >/dev/null && eval "$(mise activate zsh)"
command -v zoxide >/dev/null && eval "$(zoxide init zsh)"
command -v fzf >/dev/null && source <(fzf --zsh) 2>/dev/null
command -v starship >/dev/null && eval "$(starship init zsh)"
#
# Machine-local overrides (work credentials, host-specific tweaks) — not tracked
#
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
#zprof