-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzshrc
More file actions
375 lines (296 loc) · 9.21 KB
/
zshrc
File metadata and controls
375 lines (296 loc) · 9.21 KB
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
export TERM=vt100
# by default, we want this to get set.
# Even for non-interactive, non-login shells.
#if [ "`id -gn`" = "`id -un`" -a `id -u` -gt 99 ]; then
# umask 002
#else
umask 022
#fi
if [[ $- != *i* ]]; then
# Shell is non-interactive. Be done now
return
fi
HISTFILE=~/.histfile
HISTSIZE=1000
SAVEHIST=1000
#-----------------------------------------------------------
# zsh options
#-----------------------------------------------------------
setopt append_history # append vs overwrite history file
setopt share_history # share between sessions
setopt HIST_IGNORE_ALL_DUPS # yep as it says
setopt EXTENDED_GLOB
setopt no_check_jobs # don't warn me about bg processes when exiting
setopt no_hup # and don't kill them, either
setopt AUTO_CD # if a command is not a command but a directory, cd into it
setopt AUTO_LIST # Automatically list choices on an ambiguous completion.
setopt AUTO_PARAM_SLASH
setopt AUTO_REMOVE_SLASH
setopt GLOB # Perform filename generation
setopt NOTIFY # This makes the shell give immediate notice of changes in job status
set -A watch $USER root
export WATCHFMT='%n has %a %l %(M:from %M :)at %T.'
bindkey -e # Emacs keybindings.
# History search with up and down arrow keys
bindkey '^[[A' history-beginning-search-backward
bindkey '^[[B' history-beginning-search-forward
#-----------------------------------------------------------
# Path fun
#-----------------------------------------------------------
# Add some directory to PATH if it really exists
# and if it really is directory and if it is not
# yet in PATH
pathmunge ()
{
if ! echo $PATH | /bin/egrep "(^|:)$1($|:)" > /dev/null 2>&1
then
if test -d $1
then
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
fi
fi
}
PATH=$PATH
pathmunge ${HOME}/bin
# Solaris fun
pathmunge /usr/ucb
pathmunge /usr/local/bin
pathmunge /usr/local/sbin
pathmunge /opt/bin after
pathmunge /opt/local/bin before
pathmunge /opt/local/sbin before
# Find java
pathmunge /usr/local/java/jdk/bin after
pathmunge /usr/jdk/latest/bin after
pathmunge /usr/local/java/pax-construct-1.4/bin
pathmunge /Developer/usr/bin
pathmunge /bin after
pathmunge /sbin after
pathmunge /usr/bin after
pathmunge /usr/sbin after
pathmunge /usr/X11/bin after
# obj-j
pathmunge /usr/local/narwhal/bin
export path
#-----------------------------------------------------------
# Set my default editer
#-----------------------------------------------------------
export EDITOR=vi
#-----------------------------------------------------------
# Dev stuff
#-----------------------------------------------------------
export MAVEN_OPTS="-Xmx1024m -Xms512m"
#-----------------------------------------------------------
# File find functionss
#-----------------------------------------------------------
function ff {
if [ $# = 1 ]; then
find . | grep -i $*
else
find $1 | grep -i $2
fi
}
function fff {
find . | grep -i $1 | grep -i $2
}
function gfind {
find . -exec grep -Hi $1 \{\} \;
}
function jfind {
noglob find . -name *java -exec grep -Hi $1 \{\} \;
}
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null | awk -F'/' '{print $NF}')
if [ $ref ]
then echo "($ref)"
fi
}
#-----------------------------------------------------------
# Dreamhost weirdness
#-----------------------------------------------------------
#if [ $HOST = "paperboy" ]
# bindkey '^?' backward-delete-char
# bindkey '^[[3~' delete-char
#fi
#-----------------------------------------------------------
# OS Fun
#-----------------------------------------------------------
case $OSTYPE in
darwin*)
export GREP_OPTIONS='--color=auto '
export LS_OPTIONS='-CFG '
export PSG_OPTIONS='auxx '
export TERM=xterm-color
;;
solaris*)
export GREP_OPTIONS=''
export LS_OPTIONS='-CF '
export PSG_OPTIONS='-auxx '
;;
linux*)
export GREP_OPTIONS='--color=auto '
export LS_OPTIONS='-CF --color=auto '
export PSG_OPTIONS='-auxx '
;;
esac
alias grep="grep $GREP_OPTIONS"
alias ls="ls $LS_OPTIONS "
alias ll='ls $LS_OPTIONS -l'
alias l="ls $LS_OPTIONS -lA"
alias l.="ls -d $LS_OPTIONS .[0-9a-zA-Z]*"
alias psg="ps $PSG_OPTIONS | grep -i"
alias find='noglob find'
alias connections="netstat -ant | awk '{print $NF}' | grep -v '[a-z]' | sort | uniq -c"
alias tweet='curl -s -u waz: -d status="$1" http://twitter.com/statuses/update.xml > /dev/null'
#-----------------------------------------------------------
# cd fun
#-----------------------------------------------------------
alias cd-='cd -'
alias cd..='cd ..'
alias cd...='cd ../..'
alias cd....='cd ../../..'
alias cd.....='cd ../../../..'
alias cd......='cd ../../../../..'
alias cd.......='cd ../../../../../..'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
alias .....='cd ../../../..'
alias ......='cd ../../../../..'
alias .......='cd ../../../../../..'
#-----------------------------------------------------------
# Colored filename-completion!!11!!!
#-----------------------------------------------------------
ZLS_COLORS="$LS_COLORS"
export ZLS_COLORS
zmodload zsh/complist 2> /dev/null
#-----------------------------------------------------------
# Colors!
#-----------------------------------------------------------
#/usr/share/zsh/4.0.2/functions/Misc/colors
# Attribute codes:
# 00 none
# 01 bold
# 02 faint 22 normal
# 03 standout 23 no-standout
# 04 underline 24 no-underline
# 05 blink 25 no-blink# 07 reverse 27 no-reverse
# 08 conceal
# Text color codes:
# 30 black 40 bg-black
# 31 red 41 bg-red
# 32 green 42 bg-green
# 33 yellow 43 bg-yellow
# 34 blue 44 bg-blue
# 35 magenta 45 bg-magenta
# 36 cyan 46 bg-cyan
# 37 white 47 bg-white
# 39 default 49 bg-default
#PS1="%{"$'\e[01;31m'"%}$PS1%{"$'\e[00m'"%}"
# ^^ ^^ ^^
# | | |
# bold red reset
#export FOO="%{"$'\e[31m'"%}"#PS1="${FOO}$PS1%{"$'\e[0m'"%}"
# DEFINE ALL COLORS IN THIS PLACE
# for example color for "%h" is in variable "COLOR_p_h"
# except
# color for "%#" is in variable "COLOR_p_hash"
# color for "%/" is in variable "COLOR_p_slash"
# color for "%*" is in variable "COLOR_p_star"
# color for "@" is in variable "COLOR_at"
#COLOR="%{"$'\e[31m'"%}"
if (( EUID == 0 ))
then
COLOR_ROOT_BOLD="%{"$'\e[01m'"%}"
COLOR_RESET="%{"$'\e[39;49;01m'"%}"
else
COLOR_ROOT_BOLD=""
COLOR_RESET="%{"$'\e[39;49;00m'"%}"
fi
COLOR_REAL_RESET="%{"$'\e[39;49;00m'"%}"
colorize()
{
COLOR_p_h="%{"$'\e[32;49m'"%}"
COLOR_p_l="%{"$'\e[32;49m'"%}"
COLOR_p_y="%{"$'\e[32;49m'"%}"
COLOR_p_n="%{"$'\e[35;49m'"%}"
COLOR_at="%{"$'\e[35;49m'"%}"
COLOR_p_m="%{"$'\e[35;49m'"%}"
COLOR_WHOLEHOST="%{"$'\e[35;49m'"%}"
COLOR_SHORTHOST="%{"$'\e[35;49m'"%}"
COLOR_DOMAINHOST="%{"$'\e[35;49m'"%}"
COLOR_p_D="%{"$'\e[31;46m'"%}"
COLOR_MY_DATE="%{"$'\e[31;46m'"%}"
COLOR_p_star="%{"$'\e[31;46m'"%}"
COLOR_MY_TIME="%{"$'\e[31;46m'"%}"
COLOR_ROOT="%{"$'\e[01;31;43m'"%}"
if (( EUID == 0 ))
then
COLOR_p_hash="${COLOR_ROOT}"
COLOR_p_slash="${COLOR_ROOT}"
else
COLOR_p_hash="%{"$'\e[01;03;33;49m'"%}"
COLOR_p_slash="%{"$'\e[34;49m'"%}"
fi
$LATEST_PROMPT
}
uncolorize()
{
COLOR_p_h="${COLOR_RESET}"
COLOR_p_l="${COLOR_RESET}"
COLOR_p_y="${COLOR_RESET}"
COLOR_p_n="${COLOR_RESET}"
COLOR_at="${COLOR_RESET}"
COLOR_p_m="${COLOR_RESET}"
COLOR_WHOLEHOST="${COLOR_RESET}"
COLOR_SHORTHOST="${COLOR_RESET}"
COLOR_DOMAINHOST="${COLOR_RESET}"
COLOR_p_D="${COLOR_RESET}"
COLOR_MY_DATE="${COLOR_RESET}"
COLOR_p_star="${COLOR_RESET}"
COLOR_MY_TIME="${COLOR_RESET}"
COLOR_ROOT="%{"$'\e[39;49;01m'"%}"
if (( EUID == 0 ))
then
COLOR_p_hash="%s${COLOR_ROOT}"
COLOR_p_slash="%s${COLOR_ROOT}"
else
COLOR_p_hash="${COLOR_RESET}"
COLOR_p_slash="${COLOR_RESET}"
fi
$LATEST_PROMPT
}
colorize
#uncolorize
#-----------------------------------------------------------
# Prompts
#-----------------------------------------------------------
cuttwolineprompt()
{
export PS1="${COLOR_ROOT_BOLD}${COLOR_ROOT}%S${ROOTTEXT}%s${COLOR_RESET}$ROOTPROMPTADD${COLOR_p_n}%n${COLOR_RESET}${COLOR_at}@${COLOR_RESET}${COLOR_p_m}%m${COLOR_RESET} : ${COLOR_p_slash}%/${COLOR_RESET}
${COLOR_p_hash}%#${COLOR_REAL_RESET} "
#export RPROMPT="${COLOR_ROOT_BOLD}${COLOR_p_h}%h${COLOR_RESET} | ${COLOR_p_y}%y${WINDOW:+.${WINDOW}}${COLOR_REAL_RESET}"
LATEST_PROMPT="cuttwolineprompt"
}
defaultprompt()
{
# CHOOSE ONE PROMPT
#longprompt
#twolineprompt
cuttwolineprompt
#threelinetimeprompt
#cutthreelinetimeprompt
}
defaultprompt
#-----------------------------------------------------------
# Watching for other users
#-----------------------------------------------------------
LOGCHECK=60
WATCHFMT="[%B%t%b] %B%n%b has %a %B%l%b from %B%M%b"
ROOTTEXT=%(!.-=*[ROOT ZSH]*=-.)
ROOTPROMPTADD=%(!. .)
ROOTTITLEADD=%(!. | .)