blob: 63b60b63c6eec7bf0b4bd5fdd7428ede7d9da03d (
plain)
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
|
# -*- mode: sh; -*-
source $HOME/.zplugin/bin/zplugin.zsh
autoload -Uz _zplugin
(( ${+_comps} )) && _comps[zplugin]=_zplugin
HISTSIZE=10000
SAVEHIST=20000
HISTFILE=${XDG_CACHE_HOME:=$HOME/.cache}/zsh/history
setopt extended_history
setopt hist_save_no_dups
setopt hist_ignore_space
unsetopt share_history
setopt inc_append_history_time
WORDCHARS=${${WORDCHARS//[-.=]}//[\/]}
export EDITOR=emacsclient
alias ec=emacsclient
alias open-project=projectile
_emacs_function () {
emacsclient -e "($1 \"$2\")" > /dev/null
}
projectile () {
_emacs_function projectile-switch-project-by-name ${1:-$PWD}
}
set-emacs-ssh-agent () {
emacsclient -e "(setenv \"SSH_AUTH_SOCK\" \"$SSH_AUTH_SOCK\")"
}
yarn () {
PREFIX=$HOME/.local command yarn "$@"
}
ls='\ls'
gnu_ls_options="-v --group-directories-first --color=auto"
gnu_ls_isodate="--time-style=long-iso"
bsd_ls_options="-p"
bsd_ls_isodate="-D '%F %k:%M'"
case $os in
darwin)
if [[ -n $commands[gls] ]]
then
ls='\gls'
ls_options=$gnu_ls_options
ls_isodate=$gnu_ls_isodate
else
export CLICOLOR=1
ls_options=$bsd_ls_options
ls_isodate=$bsd_ls_isodate
fi
;;
freebsd)
ls_options=$bsd_ls_options
ls_isodate=$bsd_ls_isodate
;;
linux)
ls_options=$gnu_ls_options
ls_isodate=$gnu_ls_isodate
;;
esac
alias l="${ls} ${ls_options} -Bp"
alias l1="${ls} ${ls_options} -1"
alias ls="${ls} ${ls_options} -hF"
alias la="${ls} ${ls_options} -hA"
alias ll="${ls} ${ls_options} ${ls_isodate} -hl"
alias lal="ll -A"
alias lla="lal"
alias llr="ll -t"
alias https="http --default-scheme https"
zmodload zsh/terminfo
bindkey -e
bindkey '\e[3~' delete-char
bindkey '\C-hd' describe-key-briefly
backward-argument () {
local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\""
zle backward-word
}
forward-argument () {
local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\""
zle forward-word
}
kill-argument () {
local WORDCHARS="\!\`~#@$%^&*()-_=+[{]}\|;:,<.>/?\'\""
zle backward-argument
zle kill-word
}
zle -N backward-argument
zle -N forward-argument
zle -N kill-argument
bindkey '\e^b' backward-argument
bindkey '\e^f' forward-argument
bindkey '\e^k' kill-argument
sort=${commands[gsort]:-$commands[sort]}
ds () {
du -hd1 $1 | $sort -h
}
# returns the first ghq root, whereas $GHQ_ROOT returns all
hash -d p=$(ghq root)
hash -d go=${GOPATH:-$HOME/go}
zle -C hist-complete complete-word _generic
zstyle ':completion:hist-complete:*' completer _history
bindkey '\e ' hist-complete
zstyle ':completion:*' matcher-list 'm:{a-zA-Z-_}={A-Za-z_-}' 'r:|=*' 'l:|=* r:|=*'
zstyle ':completion:*' completer _expand _complete _match
if [[ $os != "darwin" && -n $commands[gpg-connect-agent] ]]
then
# When using SSH support, use the current TTY for passphrase prompts
gpg-connect-agent updatestartuptty /bye > /dev/null
# Point the SSH_AUTH_SOCK to the one handled by gpg-agent
if [ -S $(gpgconf --list-dirs agent-ssh-socket) ]; then
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
else
echo "$(gpgconf --list-dirs agent-ssh-socket) doesn't exist. Is gpg-agent running ?"
fi
elif [[ -z "$SSH_AUTH_SOCK" && -n $commands[ssh-agent] ]]
then
eval $(ssh-agent)
fi
# Plugins
zplugin ice blockf wait'0' lucid
zplugin light "zsh-users/zsh-completions"
zplugin ice wait'1' lucid
zplugin light "hlissner/zsh-autopair"
zplugin ice atload'alias kx=kubectx' cp'kube-aliases.plugin.zsh -> kube.plugin.zsh' atclone'sed -i s+"$ZSH_CUSTOM/plugins/zsh-kubernetes+$PWD+" kube.plugin.zsh' atpull'%atclone' pick'kube.plugin.zsh'
zplugin light "dbz/kube-aliases"
zplugin ice wait'1' lucid atinit'alias cdg=cd-gitroot'
zplugin load "mollifier/cd-gitroot"
zplugin ice wait'[[ -n ${ZLAST_COMMANDS[(r)rm*]} ]]' lucid
zplugin load "MikeDacre/careful_rm"
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=7"
zplugin ice wait'1' lucid if'[[ -z $SSH_CLIENT ]]'
zplugin load "zsh-users/zsh-autosuggestions"
zplugin ice wait'1' lucid
zplugin light "arzzen/calc.plugin.zsh"
# provides the title function and macOS title-folder sync
zplugin ice if'[[ $os -eq darwin ]]'
zplugin snippet "OMZ::lib/functions.zsh"
zplugin ice if'[[ $os -eq darwin ]]'
zplugin snippet "OMZ::lib/termsupport.zsh"
zplugin ice if'[[ $os -eq darwin ]]' wait'1' lucid
zplugin load "unixorn/tumult.plugin.zsh"
zplugin ice wait'[[ -n ${ZLAST_COMMANDS[(r)npm*]} ]]' lucid
zplugin light "lukechilds/zsh-better-npm-completion"
zplugin ice wait'[[ -n ${ZLAST_COMMANDS[(r)nix*]} ]]' lucid
zplugin light "spwhitt/nix-zsh-completions"
zplugin ice if'[[ -n $commands[ghq] ]]'
zplugin light "${GOPATH:=$HOME/go}/src/github.com/motemen/ghq/zsh"
if [[ -n $commands[gcloud] ]]
then
autoload bashcompinit
bashcompinit
source ${$(readlink =gcloud):h}/../etc/bash_completion.d/gcloud.inc
fi
if [[ -n $commands[helm] ]]
then
autoload _helm
compdef _helm helm
fi
# General configuration
if [[ -n $commands[gpg2] && -z $commands[gpg] ]]
then
alias gpg=gpg2
fi
if [[ -n $commands[lunchy] ]]
then
LUNCHY_DIR=$(dirname $(gem which lunchy))/../extras
if [ -f $LUNCHY_DIR/lunchy-completion.zsh ]; then
. $LUNCHY_DIR/lunchy-completion.zsh
fi
fi
PROMPT='%B%F{green}%n %F{blue}%~%b
%# '
if [[ $TERM == "dumb" ]]
then
unsetopt zle
else
AGKOZAK_PROMPT_DIRTRIM=0
AGKOZAK_LEFT_PROMPT_ONLY=$SSH_CLIENT
check_kubectl_context () {
if [[ "$PWD" =~ /kubernetes ]]
then
kubectl_context=$(kubectl config current-context)
if [[ $kubectl_context =~ production ]]
then
prompt_context="%F{red}[${kubectl_context}]%f"
else
prompt_context="%F{yellow}[${kubectl_context}]%f"
fi
else
prompt_context=
fi
}
precmd_functions+=(check_kubectl_context)
AGKOZAK_CUSTOM_RPROMPT='${prompt_context}%(3V.%F{${AGKOZAK_COLORS_BRANCH_STATUS}%3v%f.)'
fi
zplugin light agkozak/agkozak-zsh-prompt
zplugin light "mollifier/anyframe"
if [[ -n $commands[fzf] ]]
then
zplugin snippet "https://github.com/junegunn/fzf/raw/master/shell/key-bindings.zsh"
export FZF_CTRL_T_COMMAND='
(git ls-tree -r --name-only HEAD ||
fd --hidden --follow --exclude ".git" . |
sed s/^..//) 2> /dev/null'
export FZF_ALT_C_COMMAND='fd --type d --hidden --follow --exclude ".git" .'
export FZF_DEFAULT_COMMAND=$FZF_CTRL_T_COMMAND
bindkey '^t' transpose-chars
bindkey '^x^f' fzf-file-widget
zstyle ":anyframe:selector:fzf:" command "fzf --height 40%"
bindkey '\es' anyframe-widget-cd-ghq-repository
bindkey '^x^k' anyframe-widget-kill
fi
unsetopt flow_control # Let me use ^S and ^Q
zplugin ice wait'1' if'[[ -z $SSH_CLIENT ]]' lucid #atinit'zpcompinit; zpcdreplay -q'
zplugin load "zdharma/fast-syntax-highlighting"
|