-
Notifications
You must be signed in to change notification settings - Fork 0
/
.zshrc
343 lines (281 loc) · 8.44 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
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# users generic .zshrc file for zsh(1)
## Environment variable configuration
#
# LANG
#
export LANG=ja_JP.UTF-8
## Default shell configuration
#
# set prompt
#
autoload colors
colors
case ${UID} in
0)
PROMPT="%B%{${fg[red]}%}%/#%{${reset_color}%}%b "
PROMPT2="%B%{${fg[red]}%}%_#%{${reset_color}%}%b "
SPROMPT="%B%{${fg[red]}%}%r is correct? [n,y,a,e]:%{${reset_color}%}%b "
[ -n "${REMOTEHOST}${SSH_CONNECTION}" ] &&
PROMPT="%{${fg[cyan]}%}$(echo ${HOST%%.*} | tr '[a-z]' '[A-Z]') ${PROMPT}"
;;
*)
PROMPT="%{${fg[red]}%}%/%%%{${reset_color}%} "
PROMPT2="%{${fg[red]}%}%_%%%{${reset_color}%} "
SPROMPT="%{${fg[red]}%}%r is correct? [n,y,a,e]:%{${reset_color}%} "
[ -n "${REMOTEHOST}${SSH_CONNECTION}" ] &&
PROMPT="%{${fg[cyan]}%}$(echo ${HOST%%.*} | tr '[a-z]' '[A-Z]') ${PROMPT}"
;;
esac
# http://d.hatena.ne.jp/mollifier/20090814/p1
autoload -Uz vcs_info
zstyle ':vcs_info:*' formats '(%s)-[%b]'
zstyle ':vcs_info:*' actionformats '(%s)-[%b|%a]'
precmd () {
psvar=()
LANG=en_US.UTF-8 vcs_info
[[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_"
}
RPROMPT="%1(v|%F{green}%1v%f|)"
setopt transient_rprompt
# auto change directory
#
setopt auto_cd
# auto directory pushd that you can get dirs list by cd -[tab]
#
setopt auto_pushd
# 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
# historical backward/forward search with linehead string binded to ^P/^N
#
autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^p" history-beginning-search-backward-end
bindkey "^n" history-beginning-search-forward-end
bindkey "\\ep" history-beginning-search-backward-end
bindkey "\\en" history-beginning-search-forward-end
## Command history configuration
#
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt hist_ignore_dups # ignore duplication command history list
setopt share_history # share command history data
## Completion configuration
#
fpath=($(brew --prefix)/share/zsh/site-functions $fpath)
autoload -U compinit
compinit
## zsh editor
#
autoload zed
## Prediction configuration
#
#autoload predict-on
#predict-off
## 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"
alias screen="screen -U -D -RR"
alias hg="nocorrect hg"
# alias npm="nocorrect npm"
case "${OSTYPE}" in
freebsd*|darwin*)
alias ls="ls -G -w"
;;
linux*)
alias ls="ls --color"
;;
esac
alias la="ls -a"
alias lf="ls -F"
alias ll="ls -l"
alias du="du -h"
alias df="df -h"
alias su="su -l"
alias sgi32="sudo env ARCHFLAGS="-Os -arch i386 -fno-common" gem install"
alias sgi64="sudo env ARCHFLAGS="-Os -arch x86_64 -fno-common" gem install"
alias sgi="sgi64"
case "${OSTYPE}" in
darwin*)
alias updateports="sudo port selfupdate; sudo port outdated"
alias portupgrade="sudo port upgrade installed"
alias Emacs='open -a /Applications/Emacs.app/Contents/MacOS/Emacs'
alias emacs="/usr/local/Cellar/emacs/23.3b/Emacs.app/Contents/MacOS/Emacs -nw"
# alias vi=vim='env LANG=ja_JP.UTF-8 /Applications/MacVim.app/Contents/MacOS/Vim -u $HOME/.zshrc "$@"'
;;
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=01;34:ln=01;35:so=01;32:ex=01;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;1' 'ln=;35;1' 'so=;32;1' 'ex=31;1' 'bd=46;34' 'cd=43;34'
;;
esac
# set terminal title including current directory
#
case "${TERM}" in
kterm*|xterm*)
precmd() {
echo -ne "\033]0;${USER}@${HOST%%.*}:${PWD}\007"
}
export LSCOLORS=exfxcxdxbxegedabagacad
export LS_COLORS='di=34:ln=35:so=32:pi=33: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
## load user .zshrc configuration file
#
[ -f ~/.zshrc.mine ] && source ~/.zshrc.mine
export LC_CTYPE="ja_JP.UTF-8"
export PATH=/usr/local/bin:/usr/local/sbin:$PATH
export PATH=$HOME/download/flex_sdk_3/bin:$PATH
export GAEJ_HOME=~/appengine-java-sdk-1.2.2
export PATH=$PATH:$JRUBY_HOME/bin:$GAEJ_HOME/bin
export PATH=~/chromium/depot_tools:"$PATH"
export PATH=~/src/gistp:"$PATH"
export PATH=~/hatena-diary-writer:"$PATH"
export PATH=/usr/local/mysql/bin:"$PATH"
export PATH=~/perl5/perlbrew/bin:"$PATH"
export PATH="$PATH":"$HOME/bin"
case "${OSTYPE}" in
darwin*)
export PATH=/usr/local/Cellar/android-sdk/r7/bin:"$PATH"
export PATH=/usr/local/Cellar/android-sdk/r7/tools:"$PATH"
export PATH="$HOME/Library/Haskell/bin:$PATH"
;;
esac
export GISTY_DIR="$HOME/gists"
[[ -s $HOME/perl5/perlbrew/etc/bashrc ]] && source $HOME/perl5/perlbrew/etc/bashrc
[[ -s $HOME/.rvm/scripts/rvm ]] && source $HOME/.rvm/scripts/rvm
if [ -s $HOME/.pythonbrew/etc/bashrc ]
then
source $HOME/.pythonbrew/etc/bashrc
export VIRTUALENVWRAPPER_PYTHON=$HOME/.pythonbrew/pythons/Python-2.5.5/bin/python
source $HOME/.pythonbrew/pythons/Python-2.5.5/bin/virtualenvwrapper.sh
export VIRENV_USE_DISTRIBUTE=1
export WORKON_HOME=$HOME/.virtualenvs
fi
if [ -s /usr/share/vim/vim73/macros/less.sh ]
then
alias vless="/usr/share/vim/vim73/macros/less.sh"
fi
if [ -s /usr/share/vim/vimcurrent/macros/less.sh ]
then
alias vless="/usr/share/vim/vimcurrent/macros/less.sh"
fi
alias hg="hg --encoding=utf-8"
# source $HOME/.nvm/nvm.sh
alias pad="plackup -MPlack::App::Directory \
-e 'Plack::App::Directory->new->to_app'"
alias ec="emacsclient -n"
export EDITOR=vim
alias be='bundle exec'
perl -wle \
'do { print qq/(setenv "$_" "$ENV{$_}")/ if exists $ENV{$_} } for @ARGV' \
PATH > $HOME/.emacs.d/shellenv.el
export GOOGLE_KEY=anonymous
export GOOGLE_SECRET=anonymous
export PATH=$HOME/.nodebrew/current/bin:$PATH
[[ -x "`which npm 2>/dev/null`" ]] && . <(npm completion)
export JSTESTDRIVER_HOME=~/bin
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
# rbenv
if [ -d ${HOME}/.rbenv ] ; then
export PATH="${HOME}/.rbenv/bin:${HOME}/.rbenv/shims:${PATH}"
eval "$(rbenv init --no-rehash -)"
fi
# plenv
if [ -d ${HOME}/.plenv ] ; then
export PATH=${HOME}/.plenv/bin/:${HOME}/.plenv/shims:${PATH}
eval "$(plenv init -)"
fi
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
export PYENV_ROOT=/usr/local/opt/pyenv
export PATH=${PYENV_ROOT}/shims/:$PATH
[ -d ${HOME}/.mysqlenv ] && source ~/.mysqlenv/etc/bashrc
export LDFLAGS=-L/usr/local/opt/readline/lib
export CPPFLAGS=-I/usr/local/opt/readline/include
export GOPATH=$HOME
export PATH=$PATH:$GOPATH/bin
export PATH="$PATH":$HOME/bin/depot_tools
# added by travis gem
[ -f ${HOME}/.travis/travis.sh ] && source ${HOME}/.travis/travis.sh
[ -f ${HOME}/.zshrc-e ] && source ${HOME}/.zshrc-e
peco-src() {
local selected
selected="$(ghq list --full-path | peco --query="$LBUFFER")"
if [ -n "$selected" ]; then
BUFFER="cd $selected"
zle accept-line
fi
zle reset-prompt
}
zle -N peco-src
bindkey '^]' peco-src
# http://blog.64p.org/entry/2016/03/20/130716
source "${HOME}/.zgen/zgen.zsh"
if ! zgen saved; then
zgen oh-my-zsh
zgen oh-my-zsh themes/robbyrussell
zgen oh-my-zsh plugins/git
zgen oh-my-zsh plugins/ssh-agent
zgen load zsh-users/zsh-syntax-highlighting
zgen load "zsh-users/zsh-completions"
zgen save
fi
[ -f ${HOME}/.zshenv ] && source "${HOME}/.zshenv"
[ -f ${HOME}/.zsh_env ] && source "${HOME}/.zsh_env"