-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzshrc
258 lines (211 loc) · 7.5 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
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export EDITOR=vim
export TERM=screen-256color
setopt nobeep
#---------------------------------------------------------------------------
# History
#---------------------------------------------------------------------------
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt hist_ignore_dups
setopt share_history
setopt hist_no_store
setopt hist_reduce_blanks
setopt extended_history
setopt inc_append_history
setopt hist_ignore_space
setopt hist_verify
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
#---------------------------------------------------------------------------
# Complement
#---------------------------------------------------------------------------
autoload -U compinit
compinit
setopt auto_pushd
setopt correct
setopt correct_all
setopt hist_expand
setopt list_types
setopt auto_list
setopt auto_menu
setopt list_packed
setopt auto_param_keys
setopt auto_param_slash
setopt mark_dirs
setopt auto_cd
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
setopt nolistbeep
#---------------------------------------------------------------------------
# Appearance
#---------------------------------------------------------------------------
autoload -U colors
colors
setopt prompt_subst
export LSCOLORS=gxfxcxdxbxegedabagacad
zstyle ':completion:*' list-colors 'di=36;49'
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_"
}
#---------------------------------------------------------------------------
# Prompt
#---------------------------------------------------------------------------
PROMPT="%{${fg[yellow]}%}%/%{${reset_color}%} "
PROMPT2="%{${fg[yellow]}%}%_%{${reset_color}%} "
SPROMPT="%{${fg[red]}%}%r is correct? [n,y,a,e]:%{${reset_color}%} "
RPROMPT="%1(v|%F{green}%1v%f|)"
[ -n "${REMOTEHOST}${SSH_CONNECTION}" ] && PROMPT="%{${fg[cyan]}%}%n@${HOST%%.*} ${PROMPT}"
#---------------------------------------------------------------------------
# Alias
#---------------------------------------------------------------------------
alias ll='ls -ltrFG'
alias la='ls -lhAFG'
alias diff='colordiff'
alias sed='gsed'
alias be='bundle exec'
alias g='git'
alias gci='git commit'
alias gst='git status --short --branch'
alias glg='git log'
alias gaa='git add . -A'
alias ga='git add'
alias gd='git diff'
alias gdc='git diff --cached'
alias gco='git checkout'
alias gcp='git cherry-pick'
alias gg='git grep'
alias gb='git branch'
alias gfo='git fetch origin'
alias gpm='git pull origin master'
alias gpc='git rev-parse --abbrev-ref HEAD | git pull origin'
alias -g B='`git branch -a | peco --prompt "GIT BRANCH>" | head -n 1 | sed -e "s/^\*\s*//g"`'
alias gr='greplace'
alias gffs='git flow feature start'
alias gfff='git flow feature finish'
alias tn='tmux new -s'
alias ta='tmux attach -t'
# alias migrate='./bin/spring rake db:migrate; ./bin/annotate -i'
# alias migrate_reset='./bin/spring rake db:migrate:reset; ./bin/annotate -i'
alias migrate='./bin/rake db:migrate && RAILS_ENV=test ./bin/rake db:reset'
alias migrate_reset='./bin/rake db:migrate:reset && RAILS_ENV=test ./bin/rake db:reset'
alias nrs="sudo /etc/init.d/networking restart"
alias rs='./bin/rails s -b 0.0.0.0'
alias rc='./bin/rails c'
alias mc='mailcatcher --ip 0.0.0.0'
alias webserver='ruby -run -ehttpd . -p8000'
alias adb-show-activity="adb shell dumpsys activity top"
alias adb-show-stack="adb shell dumpsys activity | grep -B 1 \"Run #[0-9]*:\""
alias d='docker'
alias dm='docker-machine'
alias dc='docker-compose'
alias drs='dc run --service-ports web'
alias drc='dc run web ./bin/rails c'
alias drspec='dc run web ./bin/rspec'
alias drake='dc run web ./bin/rake'
alias dmigrate='dc run web ./bin/rake db:migrate && dc run -e RAILS_ENV=test web ./bin/rake db:reset'
alias dmigrate_reset='dc run web ./bin/rake db:migrate:reset && dc run -e RAILS_ENV=test web ./bin/rake db:reset'
alias tf='terraform'
alias tfp='terraform plan'
alias tfa='terraform apply'
alias tfs='terraform show'
alias is='itamae-secrets'
alias grep='grep --color'
alias docker-date-sync='docker run --rm --privileged alpine hwclock -s'
alias rn='react-native'
alias le='lerna'
alias lea='le add'
alias leb='le bootstrap'
alias lec='le clean'
# Hub
eval "$(hub alias -s)"
#---------------------------------------------------------------------------
# Others
#---------------------------------------------------------------------------
function reload() {
source $HOME/.zshrc
}
function chpwd() {
ls
}
function greplace() {
git grep -l $1 $3 | xargs sed -i -e "s/$1/$2/g"
find . -name '*-e' | xargs rm
}
function dmenv() {
eval "$(docker-machine env $1)"
}
function kill-rails-server() {
ps aux | grep "[r]ails s" | awk '{print "kill -9",$2}' | sh
}
function kill-rails-console() {
ps aux | grep "[r]ails c" | awk '{print "kill -9",$2}' | sh
}
function kill-rails() {
kill-rails-server
kill-rails-console
}
function peco-select-history() {
BUFFER=`history -n 1 | tail -r | awk '!a[$0]++' | peco`
CURSOR=$#BUFFER
zle reset-prompt
}
zle -N peco-select-history
bindkey '^r' peco-select-history
function peco-ghq-list() {
cd $(ghq root)/$(ghq list | peco)
}
zle -N peco-ghq-list
bindkey '^g' peco-ghq-list
# if [ -d $HOME/.anyenv ] ; then
# PATH=$HOME/.anyenv/bin:$PATH
# export PATH
# eval "$(anyenv init -)"
# fi
if [ -d $HOME/.rbenv ] ; then
PATH=$HOME/.rbenv/bin:$PATH
export PATH
eval "$(rbenv init -)"
fi
export GOPATH=$HOME/go
export GOENV_ROOT=$HOME/.goenv
export PATH=bin:$GOENV_ROOT/bin:$GOPATH/bin:$PATH
eval "$(goenv init -)"
export PATH="/usr/local/heroku/bin:$PATH"
export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH=${PATH}:${ANDROID_HOME}/tools
export PATH=${PATH}:${ANDROID_HOME}/emulator
export PATH=${PATH}:${ANDROID_HOME}/platform-tools
export PATH=${PATH}:${HOME}/.fastlane/bin
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
export PATH=$HOME/.nodebrew/current/bin:$PATH
function vmfavrica() {
cd ~/Vagrants/favrica > /dev/null
ps aux | grep VBoxHeadless | grep favrica -q || vagrant up
vagrant ssh
}
function git-init() {
git init
git commit -m"Initial commit" --allow-empty
}
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
# Direnv
eval "$(direnv hook zsh)"
# tabtab source for serverless package
# uninstall by removing these lines or running `tabtab uninstall serverless`
[[ -f /Users/unosk/.nodebrew/node/v8.7.0/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.zsh ]] && . /Users/unosk/.nodebrew/node/v8.7.0/lib/node_modules/serverless/node_modules/tabtab/.completions/serverless.zsh
# tabtab source for sls package
# uninstall by removing these lines or running `tabtab uninstall sls`
[[ -f /Users/unosk/.nodebrew/node/v8.7.0/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.zsh ]] && . /Users/unosk/.nodebrew/node/v8.7.0/lib/node_modules/serverless/node_modules/tabtab/.completions/sls.zsh
# tabtab source for slss package
# uninstall by removing these lines or running `tabtab uninstall slss`
[[ -f /Users/unosk/.nodebrew/node/v10.11.0/lib/node_modules/serverless/node_modules/tabtab/.completions/slss.zsh ]] && . /Users/unosk/.nodebrew/node/v10.11.0/lib/node_modules/serverless/node_modules/tabtab/.completions/slss.zsh