-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.zshrc
251 lines (194 loc) · 6.28 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
# -------------------------------------
# 環境変数
# -------------------------------------
export PATH=/usr/local/bin:$PATH
export RBENV_ROOT=/usr/local/var/rbenv
# export PATH=$HOME/.rbenv/bin:$PATH
eval "$(rbenv init -)"
# SSHで接続した先で日本語が使えるようにする
export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
# GOPATH
export PATH=$PATH:/usr/local/go/bin
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
# GAE fo GO
export PATH=$HOME/go_appengine:$PATH
# pyenv
PYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH
eval "$(pyenv init -)"
export PATH="/usr/local/opt/imagemagick@6/bin:$PATH"
export PKG_CONFIG_PATH=/usr/local/opt/imagemagick@6/lib/pkgconfig
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
# エディタ
export EDITOR=/usr/local/bin/vim
# ページャ
# export PAGER=/usr/local/bin/vimpager
# export MANPAGER=/usr/local/bin/vimpager
# alias less=$PAGER
# alias zless=$PAGER
# -------------------------------------
# zshのオプション
# -------------------------------------
## 補完機能の強化
autoload -U compinit
compinit
## 入力しているコマンド名が間違っている場合にもしかして:を出す。
setopt correct
# ビープを鳴らさない
setopt nobeep
## 色を使う
setopt prompt_subst
## ^Dでログアウトしない。
setopt ignoreeof
## バックグラウンドジョブが終了したらすぐに知らせる。
setopt no_tify
## 直前と同じコマンドをヒストリに追加しない
setopt hist_ignore_dups
# 補完
## タブによるファイルの順番切り替えをしない
unsetopt auto_menu
# cd -[tab]で過去のディレクトリにひとっ飛びできるようにする
setopt auto_pushd
# ディレクトリ名を入力するだけでcdできるようにする
setopt auto_cd
# -------------------------------------
# パス
# -------------------------------------
# 重複する要素を自動的に削除
typeset -U path cdpath fpath manpath
path=(
$HOME/bin(N-/)
/usr/local/bin(N-/)
/usr/local/sbin(N-/)
$path
)
# -------------------------------------
# プロンプト
# -------------------------------------
autoload -U promptinit; promptinit
autoload -Uz colors; colors
autoload -Uz vcs_info
autoload -Uz is-at-least
# begin VCS
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
zstyle ":vcs_info:*" max-exports 6
if is-at-least 4.3.10; then
zstyle ":vcs_info:git:*" check-for-changes true # commitしていないのをチェック
zstyle ":vcs_info:git:*" stagedstr "<S>"
zstyle ":vcs_info:git:*" unstagedstr "<U>"
zstyle ":vcs_info:git:*" formats "(%b) %c%u"
zstyle ":vcs_info:git:*" actionformats "(%s)-[%b|%a] %c%u"
fi
function vcs_prompt_info() {
LANG=en_US.UTF-8 vcs_info
[[ -n "$vcs_info_msg_0_" ]] && echo -n " %{$fg[yellow]%}$vcs_info_msg_0_%f"
}
# end VCS
#zshプロンプトにモード表示####################################
VIMODE='[i]'
function zle-keymap-select {
VIMODE="${${KEYMAP/vicmd/[n]}/(main|viins)/[i]}"
zle reset-prompt
}
zle -N zle-keymap-select
OK="^_^ "
NG="X_X "
PROMPT=""
PROMPT+="%(?.%F{green}$OK%f.%F{red}$NG%f) "
PROMPT+="%F{blue}%~%f"
PROMPT+="\$(vcs_prompt_info)"
PROMPT+="\${VIMODE}"
PROMPT+="
"
PROMPT+="%% "
RPROMPT="[%*]"
# -------------------------------------
# エイリアス
# -------------------------------------
# -n 行数表示, -I バイナリファイル無視, svn関係のファイルを無視
alias grep="grep --color --exclude='*.svn-*' --exclude='entries' --exclude='*/cache/*'"
# ls
alias ls="ls -G" # color for darwin
alias l="ls -la"
alias la="ls -la"
alias l1="ls -1"
# vim
alias vi="vim"
# tree
alias tree="tree -NC" # N: 文字化け対策, C:色をつける
# git
alias gs='git status'
alias gl='git log --graph'
alias gg="git grep --break --heading"
alias gche="git checkout"
alias gcom="git commit -v -n"
alias ga="git add"
alias gaa="git add ."
alias gp="git push origin HEAD"
alias gf="git fetch"
alias g='git'
alias -g B='`git branch -a | peco --prompt "GIT BRANCH>" | head -n 1 | sed -e "s/^\*\s*//g"`'
alias -g R='`git remote | peco --prompt "GIT REMOTE>" | head -n 1`'
alias -g LR='`git branch -a | peco --query "remotes/ " --prompt "GIT REMOTE BRANCH>" | head -n 1 | sed "s/^\*\s*//" | sed "s/remotes\/[^\/]*\/\(\S*\)/\1 \0/"`'
# -------------------------------------
# キーバインド
# -------------------------------------
bindkey -v
bindkey -M viins 'jj' vi-cmd-mode
function cdup() {
echo
cd ..
zle reset-prompt
}
zle -N cdup
bindkey '^K' cdup
bindkey "^R" history-incremental-search-backward
# -------------------------------------
# その他
# -------------------------------------
# cdしたあとで、自動的に ls する
function chpwd() { ls -1 }
# iTerm2のタブ名を変更する
function title {
echo -ne "\033]0;"$*"\007"
}
alias tmux="TERM=screen-256color-bce tmux"
# history
# 履歴ファイルの保存先
export HISTFILE=${HOME}/.zsh_history
# メモリに保存される履歴の件数
export HISTSIZE=1000
# 履歴ファイルに保存される履歴の件数
export SAVEHIST=100000
# 重複を記録しない
setopt hist_ignore_dups
# 開始と終了を記録
setopt EXTENDED_HISTORY
if which swiftenv > /dev/null; then eval "$(swiftenv init -)"; fi
export PATH=$HOME/.pyenv/shims:$PATH
# The next line updates PATH for the Google Cloud SDK.
if [ -f '/Users/ichikawayuki/Downloads/google-cloud-sdk/path.zsh.inc' ]; then source '/Users/ichikawayuki/Downloads/google-cloud-sdk/path.zsh.inc'; fi
# The next line enables shell command completion for gcloud.
if [ -f '/Users/ichikawayuki/Downloads/google-cloud-sdk/completion.zsh.inc' ]; then source '/Users/ichikawayuki/Downloads/google-cloud-sdk/completion.zsh.inc'; fi
function tmux-remake-socket () {
if [ ! $TMUX ]; then
return
fi
tmux_socket_file=`echo $TMUX|awk -F, '{print $1}'`
if [ ! -S $tmux_socket_file ]; then
mkdir -m700 `dirname $tmux_socket_file` 2> /dev/null
killall -SIGUSR1 tmux
else
echo tmux unix domain socket exists! nothing to do.
fi
unset tmux_socket_file
}
export PATH=$HOME/.nodenv/bin:$PATH
eval "$(nodenv init -)"
export PATH="/usr/local/opt/[email protected]/bin:$PATH"