-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
240 lines (200 loc) · 5.38 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
# users generic .zshrc file for zsh(1)
## Environment variable configuration
## Default shell configuration
#
# set prompt
#
autoload colors; colors
autoload -Uz add-zsh-hook
autoload -Uz is-at-least
# vcs_info
if is-at-least 4.3.10; then
autoload -Uz vcs_info
zstyle ':vcs_info:*' formats '%f(%F{cyan}%s%f:%F{green}%b%f)'
zstyle ':vcs_info:*' actionformats '%f(%F{cyan}%s%f:%F{green}%b%f|%F{red}%a%f)'
zstyle ':vcs_info:(svn|bzr):*' branchformat '%F{green}%b%f:%F{yellow}r%r%f'
zstyle ":vcs_info:git:*" check-for-changes true
zstyle ":vcs_info:git:*" stagedstr '+'
zstyle ":vcs_info:git:*" unstagedstr '-'
zstyle ':vcs_info:git:*' formats '%f(%F{green}%b%f%F{green}%c%F{red}%u%f)'
zstyle ':vcs_info:git:*' actionformats '%f(%F{green}%b%f|%F{red}%a%f%F{green}%c%F{red}%u%f)'
function _precmd_vcs_info () {
psvar=()
LANG=en_US.UTF-8 vcs_info
psvar[1]="$vcs_info_msg_0_"
}
add-zsh-hook precmd _precmd_vcs_info
fi
setopt prompt_subst
case "${OSTYPE}" in
darwin*)
local PROMCOL=$'%F{$[1+RANDOM%6]}'
PROMPT='%(?.%F{green}:)%f.%F{red}:(%f) '$PROMCOL'%l${WINDOW:+":$WINDOW"}:%h%F{green}$psvar[1]%f%(!.#.$) '
;;
*)
case "$USER" in
*admin)
local PROMCOL=$'%F{1}'
;;
root)
local PROMCOL=$'%f'
;;
*)
local PROMCOL=$'%F{4}'
;;
esac
PROMPT=$PROMCOL'[${USER}@${HOST%%.*}]%f%(!.#.$) '
;;
esac
RPROMPT='[%39<...<%~]'
# auto change directory
#
setopt auto_cd
# auto directory pushd that you can get dirs list by cd -[tab]
#
setopt auto_pushd
# select with cursor keys
#
setopt auto_menu
zstyle ':completion:*:default' menu select=1
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin \
/usr/sbin /usr/bin /sbin /bin
# command correct edition before each completion attempt
#
setopt correct
# compacked complete list display
#
setopt list_packed
# no remove postfix slash of command line
#
setopt noautoremoveslash
# no beep sound when complete list displayed
#
setopt nolistbeep
## Keybind configuration
#
# emacs like keybind (e.x. Ctrl-a goes to head of a line and Ctrl-e goes
# to end of it)
#
bindkey -e
# Backspace / Delete
bindkey "" backward-delete-char
bindkey "[3~" delete-char
# Home / End
bindkey "[1~" beginning-of-line
bindkey "[4~" end-of-line
# Page Up / Down
bindkey "[5~" beginning-of-history
bindkey "[6~" end-of-history
## Command history configuration
#
HISTFILE=${HOME}/.zsh_history
HISTSIZE=100000
SAVEHIST=100000
setopt hist_ignore_dups # ignore duplication command history list
setopt share_history # share command history data
bindkey '^R' history-incremental-pattern-search-backward
bindkey '^S' history-incremental-pattern-search-forward
# print system execution times
REPORTTIME=1
## Completion configuration
#
fpath=(${HOME}/.zsh.d/functions ${HOME}/.zsh-completions ${fpath})
autoload -U compinit
compinit
# auto push
setopt auto_pushd
# list packed
setopt list_packed
## Alias configuration
#
# expand aliases before completing
#
setopt complete_aliases # aliased ls needs if file/dir completions work
alias where="command -v"
alias j="jobs -l"
case "${OSTYPE}" in
freebsd*|darwin*)
alias ls="ls -G -w"
;;
linux*)
alias ls="ls --color"
;;
esac
alias la="ls -Fa"
alias lf="ls -F"
alias ll="ls -l"
alias du="du -h"
alias df="df -h"
alias su="su -l"
alias rm="rm -i"
alias pv="perl -le '\$m = shift; eval qq(require \$m) or die qq(module \"\$m\" is not installed \\n); print qq(\$m : ).\$m->VERSION'"
case "${OSTYPE}" in
freebsd*)
case ${UID} in
0)
updateports()
{
if [ -f /usr/ports/.portsnap.INDEX ]
then
portsnap fetch update
else
portsnap fetch extract update
fi
(cd /usr/ports/; make index)
portversion -v -l \<
}
alias appsupgrade='pkgdb -F && BATCH=YES NO_CHECKSUM=YES portupgrade -a'
;;
esac
;;
esac
## terminal configuration
#
unset LSCOLORS
case "${TERM}" in
xterm)
export TERM=xterm-color
;;
kterm)
export TERM=kterm-color
# set BackSpace control character
stty erase
;;
cons25)
unset LANG
export LSCOLORS=exfxcxdxbxegedabagacad
export LS_COLORS='di=34:ln=35:so=32:ex=31:bd=46;34:cd=43;34:su=41;30:sg=46;30:tw=42;30:ow=43;30'
zstyle ':completion:*' list-colors \
'di=34' 'ln=35' 'so=32' 'ex=31' 'bd=46;34' 'cd=43;34'
;;
esac
## custom functions
#
sha1() {
shasum $1 | awk '{print $1}' > $1.sha1
}
## set env
#
export PATH=/usr/local/sbin:/usr/local/bin:${PATH}
[ -d /usr/local/mysql ] && export PATH=/usr/local/mysql/bin:${PATH}
export PATH=${HOME}/bin:${HOME}/.plenv/bin:${HOME}/.rbenv/bin:${HOME}/.pyenv/bin:${PATH}
# smartcd
[ -r "$HOME/.smartcd_config" ] && source ~/.smartcd_config
# plenv
if which plenv > /dev/null; then eval "$(plenv init -)"; fi
# rbenv
if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi
# pyenv
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
# vcs (svn, git)
export SVN_EDITOR=/usr/bin/vim
export GIT_EDITOR=/usr/bin/vim
export EDITOR=/usr/bin/vim
## load user .zshrc configuration file
[ -f ${HOME}/.zshrc.local ] && source ${HOME}/.zshrc.local
## highlight for less
if [ -f /usr/local/bin/src-hilite-lesspipe.sh ]; then
export LESS='-R'
export LESSOPEN='| /usr/local/bin/src-hilite-lesspipe.sh %s'
fi