-
Notifications
You must be signed in to change notification settings - Fork 0
/
zshrc
280 lines (224 loc) · 7.66 KB
/
zshrc
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#!/usr/bin/env zsh
# _________ _ _ ____ ____
# |__ / ___|| | | | _ \ / ___|
# / /\___ \| |_| | |_) | |
# _ / /_ ___) | _ | _ <| |___
#(_)____|____/|_| |_|_| \_\\____|
#
###############################################################################
#
# ENVIRONMENT VARIABLES
#
###############################################################################
fpath=($fpath $HOME/.zsh/completion)
if which nvim &>/dev/null; then
export EDITOR=nvim
else
export EDITOR=vim
fi
export LESS=-R
export PAGER=less
export PATH=$HOME/git/dm/bin:$PATH
if [[ ! $PATH =~ '\.local/bin' ]]; then
export PATH=$HOME/.local/bin:$PATH
fi
export DMSALT_BATCH=50
export DMSALT_SAFE=1
export VAULT_ADDR=https://vault.dm.gg:8200
export LANG=fr_FR.UTF-8
###############################################################################
#
# LIBRARIES
#
###############################################################################
# Goto funttions
source $HOME/.zsh/lib/goto.zsh
# Jira functions
source $HOME/.zsh/lib/jira.zsh
###############################################################################
#
# GIT INTEGRATION
#
###############################################################################
###############################################################################
#
# COMPLETION
#
###############################################################################
autoload -U compinit
compinit
zstyle ':completion:*:descriptions' format '%U%B%d%b%u'
zstyle ':completion:*:warnings' format '%BSorry, no matches for: %d%b'
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \
/usr/sbin /usr/bin /sbin /bin /usr/X11R6/bin
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
# Creates a completion cache. Very useful for time consuming commands completion.
#zstyle ':completion:*' use-cache off
zstyle ':completion:*' cache-path ~/.zsh_cache
unsetopt menu_complete # do not autoselect the first completion entry
unsetopt flowcontrol
setopt auto_menu # show completion menu on succesive tab press
setopt complete_in_word
setopt always_to_end
# Ignore completion functions for commands you don’t have.
zstyle ':completion:*:functions' ignored-patterns '_*'
# Autocompletion menu
zstyle ':completion:*' menu select=2
# Extended globing
# setopt extendedglob
# Autocompletion of command line switches for aliases
setopt completealiases
# des couleurs pour la complétion
# faites un kill -9 <tab><tab> pour voir :)
zmodload zsh/complist
setopt extendedglob
zstyle ':completion:*:*:kill:*:processes' list-colors "=(#b) #([0-9]#)*=36=31"
setopt nobeep
if [[ -f $HOME/.zsh/completions/kubectl ]]; then
source $HOME/.zsh/completions/kubectl
fi
###############################################################################
#
# KEY BINDINGS
#
###############################################################################
stty -ixon
bindkey -v
# create a zkbd compatible hash;
# to add other keys to this hash, see: man 5 terminfo
typeset -A key
key[Home]=${terminfo[khome]}
key[End]=${terminfo[kend]}
key[Insert]=${terminfo[kich1]}
key[Delete]=${terminfo[kdch1]}
key[Up]=${terminfo[kcuu1]}
key[Down]=${terminfo[kcud1]}
key[Left]=${terminfo[kcub1]}
key[Right]=${terminfo[kcuf1]}
key[PageUp]=${terminfo[kpp]}
key[PageDown]=${terminfo[knp]}
autoload up-line-or-beginning-search
autoload down-line-or-beginning-search
zle -N up-line-or-beginning-search
zle -N down-line-or-beginning-search
# setup key accordingly
[[ -n "${key[Home]}" ]] && bindkey "${key[Home]}" beginning-of-line
[[ -n "${key[End]}" ]] && bindkey "${key[End]}" end-of-line
[[ -n "${key[Insert]}" ]] && bindkey "${key[Insert]}" overwrite-mode
[[ -n "${key[Delete]}" ]] && bindkey "${key[Delete]}" delete-char
[[ -n "${key[Up]}" ]] && bindkey "${key[Up]}" up-line-or-beginning-search
[[ -n "${key[Down]}" ]] && bindkey "${key[Down]}" down-line-or-beginning-search
[[ -n "${key[Left]}" ]] && bindkey "${key[Left]}" backward-char
[[ -n "${key[Right]}" ]] && bindkey "${key[Right]}" forward-char
bindkey -M viins '^R' history-incremental-pattern-search-backward
bindkey -M vicmd '^R' history-incremental-pattern-search-backward
# by default: export WORDCHARS='*?_-.[]~=/&;!#$%^(){}<>'
# we take out the slash, period, angle brackets, dash here.
#export WORDCHARS='*?_[]~=&;!#$%^(){}'
bindkey -M viins '^[[1;5D' vi-backward-word
bindkey -M vicmd '^[[1;5D' vi-backward-word
bindkey -M viins '^[[1;5C' vi-forward-word
bindkey -M vicmd '^[[1;5C' vi-forward-word
# make zsh/terminfo work for terms with application and cursor modes
case "$TERM" in
xterm*)
zle-line-init() { echoti smkx }
zle-line-finish() { echoti rmkx }
zle -N zle-line-init
zle -N zle-line-finish
;;
esac
###############################################################################
#
# HISTORY
#
###############################################################################
# number of lines kept in history
export HISTSIZE=1000
# number of lines saved in the history after logout
export SAVEHIST=1000
# location of history
export HISTFILE=~/.zhistory
setopt hist_ignore_all_dups
setopt hist_ignore_space
setopt append_history
setopt inc_append_history
setopt extended_history
setopt share_history
###############################################################################
#
# AUTO CORRETION
#
###############################################################################
unsetopt correctall
###############################################################################
#
# PROMPT
#
###############################################################################
# Promt sessings.
case $TERM in
xterm*|urxvt*|rxvt-unicode*|screen|st*)
autoload -Uz vcs_info
# precmd_vcs_info() { vcs_info }
# precmd_functions+=( precmd_vcs_info )
precmd() { vcs_info }
setopt prompt_subst
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git:*' formats '%b;%c;%u'
THEME=agnoster
source $HOME/.zsh/themes/$THEME.zsh ;;
*)
autoload -U promptinit
promptinit
prompt redhat;;
esac
###############################################################################
#
# ALIASES
#
###############################################################################
alias mv='mv -i'
alias cp='cp -i'
alias rm='rm -i'
alias t='task'
alias tl='task long'
alias tc='task calendar'
alias less='less -r'
alias tmux='TERM=screen-256color tmux -2'
alias master='git checkout master'
alias cal="cal -m"
alias m="git stash && git m && git pr && git stash pop"
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
export MYSALT_LOCAL_USER=$LOGNAME
export MYSALT_REMOTE_USER=chriss
export MYSALT_SAFE=1
# OS specific aliases
os_aliases=$HOME/.zsh/lib/aliases.$(uname -s).zsh
if [[ -f $os_aliases ]]; then
source $os_aliases
fi
local_aliases=$HOME/.zsh/lib/aliases.local.zsh
if [[ -f $local_aliases ]]; then
source $local_aliases
fi
###############################################################################
#
# GPG agent setting
#
###############################################################################
if which gpgconf &>/dev/null; then
export GPG_TTY="$(tty)"
export SSH_AUTH_SOCK=${HOME}/.gnupg/S.gpg-agent.ssh
gpgconf --launch gpg-agent
fi
###############################################################################
#
# FUNCTIONS
#
###############################################################################
function astreinte {
vim ~/Documents/Astreinte/astreintes.csv
}