1
2
3 autoload colors zsh/terminfo
4 if [[ "$terminfo[colors]" -ge 8 ]]; then
5 colors
6 export COLORTERM=yes
7 fi
8 for pr_color in cyan white yellow magenta black blue red grey green default; do
9 eval local $pr_color='%{$fg[$pr_color]%}'
10
11 eval local ${(U)pr_color}='%{$terminfo[bold]$fg[$pr_color]%}'
12 done
13 local reset="%{$terminfo[sgr0]%}"
14
15
16 if [ -f ${HOME}/.dir_colors ]; then
17 eval $(dircolors -b ${HOME}/.dir_colors)
18 elif [ -f /etc/DIR_COLORS ]; then
19 eval $(dircolors -b /etc/DIR_COLORS)
20 fi
21
22
23
24 local prmt="$RED!"
25 (( $EUID )) && local prmt=$GREEN
26
27 local conn=''
28 [[ -n $SSH_TTY ]] && local conn=$YELLOW'ssh '$default
29
30 local screen=''
31 [[ $TERM = screen* ]] && local screen=$CYAN'scr '$default
32
33 local PS1="$screen$conn$default%20<…<%~ %(?..%(20?.${cyan}susp$default.$RED%?))$prmt>$reset "
34 local NORMALPROMPT=$PS1
35 local VIPROMPT="vi$prmt»$reset "
36
37 local PS2="%_$BLUE> $reset"
38 local RPS1="$BLUE(%(1j.%j job%(2j.s.) $yellow| .)$default%n$RED@$GREEN%m$BLUE)$reset"
39
40
41
42 function parse_git_branch
43 {
44 ref=$(git symbolic-ref HEAD 2> /dev/null) || return
45 echo "${MAGENTA}${ref#refs/heads/}$reset "
46
47 }
48
49 function parse_hg_branch
50 {
51 ref=$(hg branch 2> /dev/null) || return
52 echo "${MAGENTA}${ref#refs/heads/}$reset "
53
54 }
55
56 function parse_svn_branch
57 {
58 if [[ -d '.svn' ]] then
59 echo "${MAGENTA}svn$reset "
60 fi
61 }
62
63 function setNormalPrompt() {
64 PS1="$(parse_svn_branch)$(parse_git_branch)$(parse_hg_branch)$NORMALPROMPT"
65 }
66
67
68
69
70 zle-keymap-select() {
71
72 if [[ $KEYMAP = vicmd ]]; then
73 if [[ $PS1 != $VIPROMPT* ]]; then
74 PS1=$VIPROMPT
75 zle reset-prompt
76 fi
77 else
78 if [[ $PS1 = $VIPROMPT* ]]; then
79 setNormalPrompt
80 zle reset-prompt
81 fi
82 fi
83 }
84
85 zle -N zle-keymap-select
86
87
88 export BROWSER=/usr/bin/firefox
89 export CC=gcc
90 export EDITOR='/usr/bin/vim'
91
92
93
94
95
96
97
98
99
100
101 export LANG=de_DE.utf8
102 export LC_MESSAGES=en_GB.utf8
103 export MAIL=$HOME/.maildir;
104 export NNTPSERVER='snews://news.foo.fh-furtwangen.de'
105
106 export MAVEN_OPTS="-Xms256m -Xmx512m"
107
108
109 export PATH=/usr/lib/ccache/bin:$PATH
110 export CCACHE_DIR='/var/tmp/ccache-bene'
111
112
113 alias vi='vim'
114 alias mv='nocorrect mv'
115 alias cp='nocorrect cp'
116 alias mkdir='nocorrect mkdir -p'
117 alias rd='rmdir'
118 alias ...='cd ../..'
119 alias vp='vimpager'
120
121 autoload zmv
122 alias zmv='noglob zmv -W'
123 alias py='ipython'
124 alias pt='urxvt -e ipython'
125
126 alias cal='cal -3m'
127
128
129
130
131 alias netstat='netstat -A inet -l -e'
132 alias ph="ping heise.de"
133
134
135 if [[ -f /usr/bin/inotail || -f /bin/inotail ]] then
136 alias tail='inotail'
137 fi
138
139
140 alias ls='ls -F --color=auto'
141 alias ll='ls -alhF --color=auto'
142 alias l='ls -F --color=auto'
143 alias history='history -EfdD'
144 alias h='history'
145 alias gh='h 1 | grep'
146 alias ind='/usr/src/linux/scripts/Lindent'
147
148 alias genmail='/home/bene/scripts/genmail.pl'
149 alias ranname="nc koeln.ccc.de 23";
150
151
152 alias gg='git grep -i'
153 alias log='git log --graph'
154 alias whatchanged='git whatchanged'
155 alias status='git status'
156 alias pull='git pull'
157 alias push='git push'
158 alias commit='git commit'
159 alias branch='git branch'
160
161 alias grep='grep --color=auto'
162 export PAGER='less -RMi'
163 export MANPAGER=$PAGER
164 alias less=$PAGER
165
166 alias diff='colordiff'
167 alias reboot="sudo /sbin/shutdown -r now";
168 alias .off="sudo /sbin/shutdown -h now";
169 alias .str="~/scripts/suspend.sh";
170
171
172 alias vbox="~/scripts/vbox.sh";
173
174 alias ifconfig="/sbin/ifconfig";
175
176
177
178 alias fatlady="ssh fatlady -t screen -RD";
179 alias gaia="ssh gaia";
180
181
182 alias vps="ssh vps -t tmux -u attach-session";
183 alias epia="ssh epia -t screen -RDU";
184 alias esprit="ssh esprit -t screen -RDU";
185
186 alias sb62="TERM=rxvt-unicode ssh sb62 -t screen -RDU";
187 alias sb83="TERM=rxvt-unicode ssh sb83";
188
189
190 zmodload zsh/complist
191 autoload -U zsh/zutils
192 autoload -U compinit
193 compinit
194 zstyle ':completion:*' format 'Completing %d'
195 zstyle ':completion:*' group-name ''
196 zstyle ':completion:*' verbose yes
197 zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
198 zstyle ':completion:*:kill:*' menu yes select
199 zstyle ':completion:*:kill:*' force-list always
200 zstyle ':completion:*:processes' command 'ps x -o pid,pcpu,tt,args'
201 zstyle ':completion:*:*:kill:*:processes' list-colors "=(#b) #([0-9]#)*=$color[white]=$color[red]"
202 zstyle ':completion:*:*:rm:*' file-patterns '*.o:object-files %p:all-files'
203 zstyle ':completion:*:*:wine:*' file-patterns '*.exe:executables *(-/):directories'
204 zstyle ':completion:*:*:(*pdf*|acroread|rm):*' file-sort time
205 zstyle ':completion:*' menu select=2
206
207 local LISTPROMPT=
208
209
210
211 HISTFILE=~/.history
212 HISTSIZE=3000
213 SAVEHIST=3000
214
215
216
217 setopt INC_APPEND_HISTORY
218 setopt SHARE_HISTORY
219 setopt EXTENDED_HISTORY
220 setopt HIST_IGNORE_DUPS
221 setopt HIST_EXPIRE_DUPS_FIRST
222
223 setopt NO_CLOBBER
224 setopt HIST_ALLOW_CLOBBER
225 setopt HIST_REDUCE_BLANKS
226
227 setopt NO_BEEP
228 setopt AUTO_CD
229 setopt EXTENDED_GLOB
230 setopt COMPLETE_IN_WORD
231
232 setopt CORRECT
233 setopt AUTO_PUSHD
234 local DIRSTACKSIZE=20
235 export REPORTTIME=5
236
237 setopt AUTO_MENU
238 setopt NO_LIST_AMBIGUOUS
239
240
241
242
243
244
245
246
247 bindkey -v "^[f" forward-word
248 bindkey -v "^[F" forward-word
249 bindkey -v "^[b" backward-word
250 bindkey -v "^[B" backward-word
251 bindkey -v "^R" history-incremental-search-backward
252 bindkey -v "^F" history-incremental-search-forward
253 bindkey -v "^A" beginning-of-line
254 bindkey -v "^E" end-of-line
255 bindkey -v "^[[7~" beginning-of-line
256 bindkey -v "^[[8~" end-of-line
257 bindkey -v "^[[1~" beginning-of-line
258 bindkey -v "^[[4~" end-of-line
259 bindkey -v "^ " vi-cmd-mode
260 bindkey -v "^N" up-line-or-search
261 bindkey -v "^P" down-line-or-search
262 bindkey -v "^[d" kill-word
263 bindkey -v "^[D" kill-word
264 bindkey -v "^[^?" backward-kill-word
265 bindkey -v "^H" backward-kill-word
266 bindkey -v "^k" kill-line
267 bindkey -v "^K" kill-line
268 bindkey -r "^["
269
270 accept-and-execute-line() { zle accept-line ; zle accept-line }
271 zle -N accept-and-execute-line
272 bindkey -M menuselect '^M' accept-and-execute-line
273 bindkey -M menuselect '^U' undo
274 bindkey -M menuselect '^J' accept-and-infer-next-history
275
276 local KEYTIMEOUT=5
277
278
279
280
281 function precmd () {
282 setNormalPrompt
283
284 case $TERM in
285 rxvt*|screen*|*xterm*|(dt|k)term|Eterm)
286 print -Pn "\e]2;%n@%m:%~\e\134"
287 ;;
288 linux)
289 ;;
290 esac
291 }
292
293 function leo () { firefox "http://dict.leo.org/?search=$1"; }
294 function dict () { firefox "http://dict.tu-chemnitz.de/?query=$1"; }
295
296
297
298 function wp () { dig +short txt "$1.wp.dg.cx" | perl -pe's/\\(\d{1,3})/chr $1/eg' }
299
300
301 function mcd() { mkdir "$@"; cd "$@" }
302
303
304 function tmp {
305 nr=$1
306 if [[ "$nr" -eq "" ]]; then
307 nr=1
308 fi
309
310 nr=`printf "%03d" $nr`
311 randir=/tmp/$nr
312 while [[ -d $randir ]]; do
313 nr=`printf "%03d" $(($nr+1))`
314 randir=/tmp/$nr
315 done
316 echo "creating temporary directory $randir"
317 mcd $randir
318 }
319
320 function psg {
321
322
323
324 ps ax | grep -i -P "$1"'(?!\(\?\!)'
325 }
326
327
328 function run () {
329 $@
330 local error=$?
331 if [[ $error -eq 0 ]]; then
332 notify-send "`hostname -s` | terminated:" "$1 $2" -i finish -t 0
333 else
334 notify-send "`hostname -s` | aborted:" "$1 $2" -u critical -i undo -t 0
335 fi
336 return $error
337 }
338
339
340 function d () {
341 emulate -L zsh
342 autoload -U colors
343 local color=$fg_bold[cyan]
344 integer i=0
345 dirs -p | while read dir
346 do
347 local num="${$(printf "%-4d " $i)/ /.}"
348 printf " %s $color%s$reset_color\n" $num $dir
349 (( i++ ))
350 done
351 integer dir=-1
352 read -r 'dir?Jump to directory: ' || return
353 (( dir == -1 )) && return
354 if (( dir < 0 || dir >= i ))
355 then
356 echo d: no such directory stack entry: $dir
357 return 1
358 fi
359 cd ~$dir
360 }
361
362
363 function dirty () {
364 while [ 1 ];
365 do
366 cat /proc/meminfo | perl -pe 's/(Writeback.*|Dirty.*)/\033[46;1m$1\033[0m/ig;'
367 sleep 1
368 done
369 }
370
371
372
373
374 export EC2_PRIVATE_KEY=~/.ec2/pk.pem
375 export EC2_CERT=~/.ec2/cert.pem
376
377
378
379 export LESS_TERMCAP_mb=$'\E[01;31m'
380 export LESS_TERMCAP_md=$'\E[01;31m'
381 export LESS_TERMCAP_me=$'\E[0m'
382 export LESS_TERMCAP_se=$'\E[0m'
383 export LESS_TERMCAP_so=$'\E[01;44;33m'
384 export LESS_TERMCAP_ue=$'\E[0m'
385 export LESS_TERMCAP_us=$'\E[01;32m'
386
387
388 test -f ~/.zshrc.host && . ~/.zshrc.host
389
390
391