-
Notifications
You must be signed in to change notification settings - Fork 8
/
zshrc
289 lines (252 loc) · 6.01 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
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
ZSH_THEME=""
# Set to this to use case-sensitive completion
# CASE_SENSITIVE="true"
# Comment this out to disable weekly auto-update checks
# DISABLE_AUTO_UPDATE="true"
# Uncomment following line if you want to disable colors in ls
# DISABLE_LS_COLORS="true"
# Uncomment following line if you want to disable autosetting terminal title.
# DISABLE_AUTO_TITLE="true"
# Uncomment following line if you want red dots to be displayed while waiting for completion
COMPLETION_WAITING_DOTS="true"
if [[ -z ${MY_SHELL_LEVEL} ]]; then
export MY_SHELL_LEVEL=0
else
export MY_SHELL_LEVEL=$(($MY_SHELL_LEVEL+1))
fi
export SS_DISPLAY_LIMIT=25
export ZSH_CUSTOM=~/.dotfiles/zsh_custom
plugins=(git regex-dirstack vim-interaction kubectl)
source $ZSH/oh-my-zsh.sh
source $ZSH_CUSTOM/themes/gnzh.zsh-theme
bindkey -v
bindkey -M viins 'jj' vi-cmd-mode
setopt auto_pushd
setopt pushd_silent
setopt pushd_ignore_dups
setopt ignore_eof
setopt rm_star_silent
unsetopt nomatch
unsetopt correct_all
if [ $(uname) = Darwin ]; then
export PATH=.:~/bin:/usr/local/opt/coreutils/libexec/gnubin:/usr/local/opt/gnu-sed/libexec/gnubin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
else
alias open=gnome-open
export PATH=.:buildutil:~/bin:~/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
fi
export GPGKEY=B2F6D883
export GPG_TTY=$(tty)
export EDITOR=vim
if which dircolors > /dev/null; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto -F --quoting-style=escape'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
function eecho
{
echo $@ 1>&2
}
function findWithSpec
{
local dirs=
local egrepopts="-v '\\.sw[po]\\$|/\\.git/|^\\.git/|/\\.svn/|^\\.svn/'"
local nullprint=
while [[ $# != 0 ]];
do
if [[ "$1" == "-Z" ]]; then
egrepopts="-Zz $egrepopts"
nullprint="-print0"
shift
elif [[ -d "$1" ]]; then
dirs="$dirs '$1'"
shift
else
break
fi
done
if [[ -z "$dirs" ]]; then
dirs=.
fi
eval "find $dirs $nullprint $@ | egrep $egrepopts"
}
function findsrc
{
findWithSpec "$@" '-name \*.java -o -name \*.scala -o -name Makefile -o -name \*.h -o -name \*.cpp -o -name \*.c'
}
alias findsrcz="findsrc -Z"
function findj
{
findWithSpec "$@" '-name \*.java'
}
alias findjz="findj -Z"
function finds
{
findWithSpec "$@" '-name \*.scala'
}
alias findsz="finds -Z"
function findsj
{
(finds "$@"; findj "$@")
}
alias findsjz="findsj -Z"
function findh
{
findWithSpec "$@" '-name \*.h -o -name \*.hpp'
}
alias findhz="findh -Z"
function findc
{
findWithSpec "$@" '-name \*.cpp -o -name \*.c'
}
alias findcz="findc -Z"
function findch
{
(findc "$@"; findh "$@")
}
alias findchz="findch -Z"
function findpy
{
findWithSpec "$@" '-name \*.py'
}
alias findcpy="findpy -Z"
function findf
{
findWithSpec "$@" "-type f"
}
alias findfz="findf -Z"
function findm
{
findWithSpec "$@" "-name Makefile"
}
alias findmz="findm -Z"
function findpom
{
findWithSpec "$@" "-name pom.xml"
}
alias findpomz="findpom -Z"
function findx
{
findWithSpec "$@" "-name \*.xml"
}
alias findxz="findx -Z"
function findjs
{
findWithSpec "$@" "-name \*.js"
}
alias findjsz="findjs -Z"
function findd
{
findWithSpec "$@" "-type d"
}
alias finddz="findd -Z"
function findExtension
{
local ext=
local dir=.
if [[ $# == 0 ]]; then
echo "usage: findExtension [dir] <extension>"
return 1
else
ext=$@[$#]
if [[ $# != 1 ]]; then
dir=$1
fi
fi
findWithSpec $dir '-name \*'.$ext
}
alias fe=findExtension
alias f=findWithSpec
alias fn='find . -name'
function findClass
{
local echoOnly=0
while getopts e opt
do
case $opt in
e) echoOnly=1
;;
esac
done
shift $((OPTIND-1))
local pattern="${1-}"
if [ -z "$pattern" ]; then
eecho "No pattern supplied" 1>&2
return 1
fi
echo $CLASSPATH | tr ':' '\n' | grep -v '^ *$' | \
while read entry
do
local out="====== $entry ======"
if [ "${entry%.jar}" != "$entry" ]; then
if [ -f "$entry" ]; then
if [ $echoOnly = 1 ]; then
echo "echoif \"jar tf '$entry' | egrep $pattern\" \"$out\""
else
echoif "jar tf '$entry' | egrep $pattern" "$out"
fi
fi
elif [ -d "$entry" ]; then
if [ $echoOnly = 1 ]; then
echo "echoif \"find '$entry' | egrep -i $pattern\"" "\"$out\""
else
echoif "find '$entry' | egrep -i $pattern" "\"$out\""
fi
fi
done
}
function ff
{
if [ $# = 0 ]; then
eecho "usage: ff <file>" 1>&2
return 1
fi
if [ -d "$1" ]; then
eecho "That's a directory, dumbass." 1>&2
return 1
elif [ "${1%/*}" = "$1" ]; then
firefox -new-tab "file://$(pwd)/$1"
else
"cd" "${1%/*}"
local dir="$(pwd)"
"cd" - >/dev/null
firefox -new-tab "file://$dir/${1##*/}"
fi
return 0
}
function gitall
{
find . -type d -a -name .git | while read d
do
local x=${d%.git}
echo ========= $x
(cd $x; git "$@")
done
}
# Assorted
alias swps='find . -name .\*.sw[op]'
alias rmstd='xargs rm -vf'
alias xag='xargs -0 egrep'
alias xg='xargs egrep'
alias xgi='xargs egrep -i'
alias pd="cd -"
alias sc=screen
alias scl="screen -list"
alias pgrep="pgrep -fl"
alias bc="bc -lq"
# Git related
alias grss='for f in $(find . -type d -a -name .git); do x=${f%/.git}; echo ==== $x; (cd $x; gss); done'
alias gl='git pull --ff-only'
alias gf='git fetch'
alias gd='git diff'
alias gdc='git diff --cached'
alias gcf='gc --all --fixup HEAD'
alias grebase='(export GIT_SEQUENCE_EDITOR=echo; git rebase --interactive --autosquash develop)'
alias gcfr='gcf && grebase'
alias gld="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative"
test -f ~/.zshrc_local && . ~/.zshrc_local
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
alias ls='ls --color=auto --quoting-style=literal'