-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
374 lines (320 loc) · 10.3 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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
####
# .zshrc file
#
# Maintainer : Tomoyuki MARUTA <[email protected]>
# Based On : Sotaro KARASAWA <[email protected]>
# Last Change : 2014/04/09
# https://github.com/marucc/dotfiles
####
export LANG=ja_JP.UTF-8
# パスの設定
PATH=$HOME/pear/bin:$HOME/bin:/usr/local/bin:/usr/local/sbin:$PATH:/sbin:/usr/sbin
export MANPATH=/usr/local/man:/usr/share/man
# mysql
export MYSQL_PS1="\u@\h[\d]> "
# エディタを vim に設定
export SVN_EDITOR="vim"
export EDITOR="vim"
export CLICOLOR=1
export SCREENDIR=$HOME/.screen
export LSCOLORS=ExFxCxDxBxegedabagacad
# anyenv
if [ -d $HOME/.anyenv ] ; then
export PATH="$HOME/.anyenv/bin:$PATH"
eval "$(anyenv init -)"
eval "$(rbenv init -)"
eval "$(ndenv init -)"
fi
# python
PYENV=`which-command pyenv`
VIRTUALENVWRAPPER=`$PYENV which virtualenvwrapper.sh || echo '/usr/local/bin/virtualenvwrapper.sh'`
if [ -e $VIRTUALENVWRAPPER ]; then
export VIRTUALENVWRAPPER_PYTHON=`$PYENV which python2.7`
export WORKON_HOME=${HOME}/venvs
export PIP_DOWNLOAD_CACHE=${HOME}/.pip_cache
export PIP_RESPECT_VIRTUALENV=true
export PIP_REQUIRE_VIRTUALENV=true
source $VIRTUALENVWRAPPER
fi
# zsh-notify/notify.plugin
if [ -e /usr/local/bin/terminal-notifier ]; then
export SYS_NOTIFIER="/usr/local/bin/terminal-notifier"
if [ -e ~/.zshrc.d/zsh-notify/notify.plugin.zsh ]; then
autoload add-zsh-hook
source ~/.zshrc.d/zsh-notify/notify.plugin.zsh
fi
fi
# 関数
find-grep () { find . -type f -print | xargs grep -n --binary-files=without-match $@ }
grepv () { grep -irn --binary-files=without-match $@ * | grep -v svn }
#Dircolorの読み込み
## 補完候補の色づけ
export ZLS_COLORS=$LS_COLORS
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
fpath=(~/.zshrc.d/zsh-completions/src $fpath)
# エイリアスの設定
case "${OSTYPE}" in
darwin*)
alias ls='ls -G'
;;
linux*)
# eval `dircolors -b ~/.dircolors`
alias ls='ls --color=auto'
;;
esac
if [ -e /Applications/MacVim.app/Contents/MacOS/Vim ]; then
export EDITOR=/Applications/MacVim.app/Contents/MacOS/Vim
alias vim='env LANG=ja_JP.UTF-8 /Applications/MacVim.app/Contents/MacOS/Vim "$@"'
fi
alias ll='ls -l'
alias la='ls -la'
alias dh='df -h'
alias vi='vim'
alias v='vim'
alias gd='dirs -v; echo -n "select number: "; read newdir; cd +"$newdir"'
alias gst='git status'
alias gtg='git tag'
alias gtl='list=`git tag`;echo -ne $list|grep "^release_"|sed "s/release_\(.*\)/\1/"|sort -t . -k 1,1 -k 2,2n -k 3,3n|sed "s/\(.*\)/release_\1/";echo -ne $list|grep -v "^release_"|sort'
alias gbr='git branch'
alias gbl='git fetch --prune && git branch -vv | grep ": gone]" | awk "{print $1}" | xargs -r git branch -d 2>&1 | grep -v "not found"; git branch'
alias gbla='gbl -a'
alias gdi='git diff'
alias gad='git add'
alias gmv='git mv'
alias grm='git rm'
alias gci='git commit'
alias gcia='git commit -a'
gps() {
BUF=`git push 2>&1`
CMD=`echo "$BUF" | grep 'git push --set-upstream origin' | sed 's/ *//'`
if [ -n "$CMD" ]; then
echo -n "${CMD} [Y/n] "
read ANSWER
case `echo $ANSWER | tr y Y` in
"" | Y* )
eval "$CMD" && git push --tags
;;
esac
else
git push --tags
echo "$BUF"
fi
}
alias gpl='git pull;git pull --tag'
alias gmg='git pull origin'
alias gco='git checkout'
gcor() {
BRANCH=`echo "$1" | grep '^remotes/origin/' | sed 's/^remotes\/origin\///'`
if [ -n "$BRANCH" ]; then
CMD="git checkout -b ${BRANCH} origin/${BRANCH}"
echo -n "${CMD} [Y/n] "
read ANSWER
case `echo $ANSWER | tr y Y` in
"" | Y* )
eval "$CMD"
;;
esac
else
git checkout $1
fi
}
# プロンプトの設定
autoload colors
#colors
case ${UID} in
0)
PROMPT="%B%{[31m%}%n@%m#%{[m%}%b "
PROMPT2="%B%{[31m%}%_#%{[m%}%b "
SPROMPT="%B%{[31m%}%r is correct? [n,y,a,e]:%[m%}%b "
#[ -n "${REMOTEHOST}${SSH_CONNECTION}" ] &&
#PROMPT="%{[37m%}${HOST%%.*} ${PROMPT}"
;;
*)
PROMPT="%{[36m%}%n%%%{[m%} "
PROMPT2="%{[35m%}%_%%%{[m%} "
SPROMPT="%{[31m%}%r is correct? [n,y,a,e]:%{[m%} "
[ -n "${REMOTEHOST}${SSH_CONNECTION}" ] &&
PROMPT="%{[37m%}${HOST%%.*} ${PROMPT}"
;;
esac
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 prompt_subst
## ビープを鳴らさない
setopt nobeep
## 補完候補一覧でファイルの種別をマーク表示
setopt list_types
## 補完候補を一覧表示
setopt auto_list
# ヒストリの設定
HISTFILE=~/.histfile
HISTSIZE=10000
SAVEHIST=10000
# 履歴ファイルに時刻を記録
setopt extended_history
# 補完するかの質問は画面を超える時にのみに行う。
LISTMAX=0
# 補完の利用設定
autoload -Uz compinit; compinit -u
# sudo でも補完の対象
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin
# cdのタイミングで自動的にpushd
setopt auto_pushd
# 複数の zsh を同時に使う時など history ファイルに上書きせず追加
setopt append_history
# 補完キー(Tab, Ctrl+I) を連打するだけで順に補完候補を自動で補完機能Off
#setopt no_auto_menu
# カッコの対応などを自動的に補完
setopt auto_param_keys
# ディレクトリ名の補完で末尾の / を自動的に付加し、次の補完に備える
setopt auto_param_slash
# ビープ音を鳴らさないようにする
setopt NO_beep
# 直前と同じコマンドラインはヒストリに追加しない
setopt hist_ignore_dups
# 重複したヒストリは追加しない
setopt hist_ignore_all_dups
# ヒストリを呼び出してから実行する間に一旦編集できる状態になる
setopt hist_verify
# auto_list の補完候補一覧で、ls -F のようにファイルの種別をマーク表示しない
setopt NO_list_types
# コマンドラインの引数で --prefix=/usr などの = 以降でも補完できる
setopt magic_equal_subst
# ファイル名の展開でディレクトリにマッチした場合末尾に / を付加する
setopt mark_dirs
# 8 ビット目を通すようになり、日本語のファイル名を表示可能
setopt print_eight_bit
# シェルのプロセスごとに履歴を共有
setopt share_history
# Ctrl+wで、直前の/までを削除する。
WORDCHARS='*?_-.[]~=&;!#$%^(){}<>'
# ディレクトリを水色にする。
#export LS_COLORS='di=01;36'
# ファイルリスト補完でもlsと同様に色をつける。
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
## 補完候補のカーソル選択を有効に
zstyle ':completion:*:default' menu select=1
# ディレクトリ名だけで、ディレクトリの移動をする。
setopt auto_cd
# C-s, C-qを無効にする。
setopt NO_flow_control
# 改行がなくても表示
unsetopt promptcr
# ジョブ
unsetopt hup
setopt nocheckjobs
# Emasc 風キーバインド
bindkey -e
# screen のステータスバーに現在実行中のコマンドを表示
# cd をしたときにlsを実行する
# ref. http://nijino.homelinux.net/diary/200206.shtml#200206140
if [ "$TERM" = "screen" ]; then
chpwd () {
echo -n "_`dirs`\\"
ls
}
preexec() {
# see [zsh-workers:13180]
# http://www.zsh.org/mla/workers/2000/msg03993.html
emulate -L zsh
local -a cmd; cmd=(${(z)2})
case $cmd[1] in
fg)
if (( $#cmd == 1 )); then
cmd=(builtin jobs -l %+)
else
cmd=(builtin jobs -l $cmd[2])
fi
;;
%*)
cmd=(builtin jobs -l $cmd[1])
;;
cd)
if (( $#cmd == 2)); then
cmd[1]=$cmd[2]
fi
;&
*)
echo -n "k$cmd[1]:t\\"
return
;;
esac
local -A jt; jt=(${(kv)jobtexts})
$cmd >>(read num rest
cmd=(${(z)${(e):-\$jt$num}})
echo -n "k$cmd[1]:t\\") 2>/dev/null
}
chpwd
fi
### Added by the Heroku Toolbelt
export PATH="/usr/local/heroku/bin:$PATH"
# added by travis gem
[ -f /Users/maru/.travis/travis.sh ] && source /Users/maru/.travis/travis.sh
###-begin-nativescript-completion-###
if complete &>/dev/null; then
_nativescript_completion () {
local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
nativescript completion -- "${COMP_WORDS[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
complete -F _nativescript_completion -o default nativescript
elif compctl &>/dev/null; then
_nativescript_completion () {
local cword line point words si
read -Ac words
read -cn cword
let cword-=1
read -l line
read -ln point
si="$IFS"
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
nativescript completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
compctl -K _nativescript_completion -f nativescript
fi
###-end-nativescript-completion-######-begin-tns-completion-###
if complete &>/dev/null; then
_tns_completion () {
local si="$IFS"
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
COMP_LINE="$COMP_LINE" \
COMP_POINT="$COMP_POINT" \
tns completion -- "${COMP_WORDS[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
complete -F _tns_completion -o default tns
elif compctl &>/dev/null; then
_tns_completion () {
local cword line point words si
read -Ac words
read -cn cword
let cword-=1
read -l line
read -ln point
si="$IFS"
IFS=$'\n' reply=($(COMP_CWORD="$cword" \
COMP_LINE="$line" \
COMP_POINT="$point" \
tns completion -- "${words[@]}" \
2>/dev/null)) || return $?
IFS="$si"
}
compctl -K _tns_completion -f tns
fi
###-end-tns-completion-###