-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
245 lines (209 loc) · 7.99 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
#-------------------------------------------------------------------------------
# General
#-------------------------------------------------------------------------------
# Encoding
export LC_CTYPE=ja_JP.UTF-8
export LC_ALL=ja_JP.UTF-8
export LANG=ja_JP.UTF-8
export LESSCHARSET=utf-8
# Keybind
bindkey -v
# Editor
export EDITOR=/Applications/MacVim.app/Contents/MacOS/Vim
# Path
PATH=$PATH:$HOME/local/bin:/sbin:usr/local/sbin
PATH=$PATH:$HOME/.nave/installed/0.6.2/bin
PATH=$PATH:$HOME/DB/mongodb-osx-i386-2.0.1/bin
PATH=$PATH:/Applications/android-sdk-macosx/platform-tools
export PATH
# Others
setopt complete_aliases
setopt auto_cd
setopt auto_pushd
setopt path_dirs
setopt pushd_ignore_dups
setopt correct
setopt correct_all
setopt no_clobber
setopt nolistbeep
setopt interactive_comments
autoload predict-on
#-------------------------------------------------------------------------------
# Completion
#-------------------------------------------------------------------------------
setopt auto_list
setopt list_packed
setopt list_types
setopt magic_equal_subst
setopt auto_menu
setopt auto_param_keys
setopt auto_param_slash
setopt brace_ccl
setopt noautoremoveslash
zstyle ':completion:*:sudo:*' command-path /usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin
zstyle ':completion:*' list-colors di=34 fi=0
#-------------------------------------------------------------------------------
# History
#-------------------------------------------------------------------------------
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
bindkey '^R' history-incremental-pattern-search-backward
bindkey '^S' history-incremental-pattern-search-forward
setopt hist_ignore_all_dups
setopt share_history
setopt hist_reduce_blanks
setopt inc_append_history
setopt hist_no_store
setopt hist_ignore_space
setopt hist_verify
#-------------------------------------------------------------------------------
# Cursor
#-------------------------------------------------------------------------------
bindkey "^W" forward-word
bindkey "^B" backward-word
autoload -Uz select-word-style
select-word-style default
zstyle ':zle:*' word-chars " _-./;@"
zstyle ':zle:*' word-style unspecified
#-------------------------------------------------------------------------------
# Color
#-------------------------------------------------------------------------------
autoload colors
colors
# prompt
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}"
;;
*)
DEFAULT=$'%{\e[1;0m%}'
RESET="%{${reset_color}%}"
GREEN="%{${fg[green]}%}"
BLUE="%{${fg[blue]}%}"
RED="%{${fg[red]}%}"
CYAN="%{${fg[cyan]}%}"
WHITE="%{${fg[white]}%}"
setopt prompt_subst
PROMPT='${RESET}${GREEN}${WINDOW:+"[$WINDOW]"}${RESET}%{$fg_bold[blue]%}%m ${RESET}${WHITE}%% ${RESET}'
RPROMPT='${RESET}${WHITE}[${BLUE}%(5~,%-2~/.../%2~,%~)% ${WHITE}]${WINDOW:+"[$WINDOW]"} ${RESET}'
#--------------------------------------------
# http://d.hatena.ne.jp/mollifier/20100906/p1
#--------------------------------------------
autoload -Uz add-zsh-hook
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git svn hg bzr
zstyle ':vcs_info:*' formats '(%s)-[%b]'
zstyle ':vcs_info:*' actionformats '(%s)-[%b|%a]'
zstyle ':vcs_info:(svn|bzr):*' branchformat '%b:r%r'
zstyle ':vcs_info:bzr:*' use-simple true
autoload -Uz is-at-least
if is-at-least 4.3.10; then
zstyle ':vcs_info:git:*' check-for-changes true
zstyle ':vcs_info:git:*' stagedstr "+"
zstyle ':vcs_info:git:*' unstagedstr "-"
zstyle ':vcs_info:git:*' formats '(%s)-[%c%u%b]'
zstyle ':vcs_info:git:*' actionformats '(%s)-[%c%u%b|%a]'
fi
function _update_vcs_info_msg() {
psvar=()
LANG=en_US.UTF-8 vcs_info
psvar[2]=$(_git_not_pushed)
[[ -n "$vcs_info_msg_0_" ]] && psvar[1]="$vcs_info_msg_0_"
}
add-zsh-hook precmd _update_vcs_info_msg
function _git_not_pushed()
{
if [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true" ]; then
head="$(git rev-parse HEAD)"
for x in $(git rev-parse --remotes)
do
if [ "$head" = "$x" ]; then
return 0
fi
done
echo "{?}"
fi
return 0
}
RPROMPT="%1(v|%F${CYAN}%1v%2v%f|)${vcs_info_git_pushed}${RESET}${WHITE}[${BLUE}%(5~,%-2~/.../%2~,%~)% ${WHITE}]${WINDOW:+"[$WINDOW]"} ${RESET}"
;;
esac
#-----------------------------------------------------
# http://journal.mycom.co.jp/column/zsh/009/index.html
#-----------------------------------------------------
unset LSCOLORS
case "${TERM}" in
xterm)
export TERM=xterm-color
;;
kterm)
export TERM=kterm-color
stty erase
;;
cons25)
unset LANG
export LSCOLORS=ExFxCxdxBxegedabagacad
export LS_COLORS='di=01;32:ln=01;35:so=01;32:ex=01;31:bd=46;34:cd=43;34:su=41;30:sg=46;30'
zstyle ':completion:*' list-colors \
'di=;36;1' 'ln=;35;1' 'so=;32;1' 'ex=31;1' 'bd=46;34' 'cd=43;34'
;;
kterm*|xterm*)
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
zstyle ':completion:*' list-colors \
'di=36' 'ln=35' 'so=32' 'ex=31' 'bd=46;34' 'cd=43;34'
;;
dumb)
echo "Welcome Emacs Shell"
;;
esac
#-------------------------------------------------------------------------------
# Alias
#-------------------------------------------------------------------------------
# ls
alias la="ls -la"
alias lf="ls -lF"
alias ll="ls -l"
# vi
alias vi='env LANG=ja_JP.UTF-8 /Applications/MacVim.app/Contents/MacOS/Vim "$@"'
alias vim='env LANG=ja_JP.UTF-8 /Applications/MacVim.app/Contents/MacOS/Vim "$@"'
alias gv='env LANG=ja_JP.UTF-8 /Applications/MacVim.app/Contents/MacOS/Vim -g "$@"'
alias gvim='env LANG=ja_JP.UTF-8 /Applications/MacVim.app/Contents/MacOS/Vim -g "$@"'
# ps
alias ps="ps auxwww"
# sudo
alias ss="sudo -s"
# git
alias g="git"
# bundler
alias be="bundle exec"
# extract http://d.hatena.ne.jp/jeneshicc/20110215/1297778049
extract () {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
*.tar.gz) tar xvzf $1 ;;
*.tar.xz) tar xvJf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xvf $1 ;;
*.tbz2) tar xvjf $1 ;;
*.tgz) tar xvzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.lzma) lzma -dv $1 ;;
*.xz) xz -dv $1 ;;
*) echo "don't know how to extract '$1'..." ;;
esac
else
echo "'$1' is not a valid file!"
fi
}
alias ex='extract'