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
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
|
#! /bin/false
if [ -e /etc/zsh/zshenv ]; then
. /etc/zsh/zshenv
fi
# fink on OS X
if [ -e /sw/bin/init.sh ]; then
. /sw/bin/init.sh
fi
HOSTNAME="`hostname`"
SYSTEM="`uname -s`"
ARCH="`uname -m`"
case "$TERM" in
linux) # Linux console
bindkey '\e[1~' beginning-of-line # Home
bindkey '\e[4~' end-of-line # End
bindkey '\e[3~' delete-char # Del
bindkey '\e[2~' overwrite-mode # Insert
;;
screen) # The textmode window manager
# In Linux console
bindkey '\e[1~' beginning-of-line # Home
bindkey '\e[4~' end-of-line # End
bindkey '\e[3~' delete-char # Del
bindkey '\e[2~' overwrite-mode # Insert
bindkey '\e[7~' beginning-of-line # home
bindkey '\e[8~' end-of-line # end
# In rxvt
bindkey '\eOc' forward-word # ctrl cursor right
bindkey '\eOd' backward-word # ctrl cursor left
bindkey '\e[3~' backward-delete-char # This should not be necessary!
;;
rxvt)
bindkey '\e[7~' beginning-of-line # home
bindkey '\e[8~' end-of-line # end
bindkey '\eOc' forward-word # ctrl cursor right
bindkey '\eOd' backward-word # ctrl cursor left
bindkey '\e[3~' backward-delete-char # This should not be necessary!
bindkey '\e[2~' overwrite-mode # Insert
;;
xterm*)
bindkey '\e[H' beginning-of-line # Home
bindkey '\e[F' end-of-line # End
bindkey '\e[3~' delete-char # Del
bindkey '\e[2~' overwrite-mode # Insert
bindkey "^[[5C" forward-word # ctrl cursor right
bindkey "^[[5D" backward-word # ctrl cursor left
;;
sun)
bindkey '\e[214z' beginning-of-line # Home
bindkey '\e[220z' end-of-line # End
bindkey '^J' delete-char # Del
bindkey '^H' backward-delete-char # Backspace
bindkey '\e[247z' overwrite-mode # Insert
;;
esac
## Set options
setopt extendedglob # required for some of our completion magic
setopt list_types # Put a file type indicator after file names when
# completing.
#setopt correct # Attempt spelling correction on command names only.
setopt nocorrect
#setopt print_exit_value
setopt list_ambiguous
setopt bash_auto_list # Make <tab><tab> do the right thing.
setopt list_packed # Compacter display of completion list.
setopt interactive_comments
setopt nohup # So backgrounded jobs don't get terminated when
# the shell is.
setopt autocd # make '..' cd into .., and '../projects' cd there etc.
#unsetopt CHECK_JOBS
setopt CHECK_JOBS
unsetopt BG_NICE
export HISTFILE=~/.zsh_history
export HISTSIZE=10000
export SAVEHIST=10000
setopt APPEND_HISTORY
setopt INC_APPEND_HISTORY
#setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt EXTENDED_GLOB
setopt HIST_FIND_NO_DUPS
setopt HIST_IGNORE_SPACE
case $TERM in
xterm*)
precmd() {
title=$TITLE
#print -Pn "\e]2;$title\a\e]1;\a"
print -Pn "\033]0;$title\007"
};
preexec() {
title="$1 [$TITLE]"
title=`echo $title | tr '\n' ' '`
#print -Pn "\e]2;$title\a\e]1;\a"
print -Pn "\033]0;$title\007"
};
;;
screen*)
if [ -x /usr/bin/screen ] || [ -x /usr/local/bin/screen ]; then
if grep -i -q screen <<< $TERMCAP ; then
precmd () {p=`print -Pn "%~"`; screen -X title "<$p>";}
preexec () {p=`print -Pn "%~:$1"`; screen -X title "<$p>";}
fi
fi;
;;
esac
## Export environment
if [ -x /usr/bin/lesspipe ] ; then
eval `lesspipe`
fi
export CVS_RSH=ssh
export RSYNC_RSH=ssh
export CVSROOT=weasel@cvs.noreply.org:/var/cvs/weasel/debian
export CVSDEB_ROOTDIR=$HOME/projects/debian/Packages
export DEBEMAIL="weasel@debian.org"
# in 'foo bar | baz' make a second ^W not eat 'bar |', but only '|'
# this has the disadvantage that in 'bar|baz' it eats all of it.
typeset WORDCHARS='|'$WORDCHARS
# malsync
export PILOTRATE=115200
alias malsync='malsync -p proxy -r 3128'
alias spider='/usr/lib/python2.1/site-packages/PyPlucker/Spider.py -f WeaselsPalmHome'
if [ "$SYSTEM" = "Linux" ] ; then
eval `dircolors`
LS_COLORS="$LS_COLORS""*.divx=01;35:"
alias ls='ls --color=auto -F'
alias grep='grep --color'
fi
alias ll='ls -l'
alias la='ls -la'
alias l='ls -l'
alias cp='cp -i'
alias mv='mv -i'
alias mmv='noglob mmv'
alias zinterdiff='interdiff -z'
alias tgrep='grep --binary-file=without-match'
alias slrn='slrn --inews'
alias defaultfixed='echo -n -e "\033]50;fixed\007"'
alias default='echo -n -e "\033]50;-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso8859-15\007"'
alias hide='echo -n -e "\033]50;nil2\007"'
alias tiny='echo -n -e "\033]50;-misc-fixed-medium-r-normal--7-70-75-75-c-50-iso8859-15\007"'
alias small='echo -n -e "\033]50;-misc-fixed-medium-r-normal--10-100-75-75-c-60-iso8859-15\007"'
alias medium='echo -n -e "\033]50;-misc-fixed-medium-r-normal--13-120-75-75-c-70-iso8859-15\007"'
alias large='echo -n -e "\033]50;-misc-fixed-medium-r-normal--15-140-75-75-c-90-iso8859-15\007"'
alias huge='echo -n -e "\033]50;-misc-fixed-medium-r-normal--20-200-75-75-c-100-iso8859-15\007"'
[[ -x /usr/sbin/traceroute ]] && alias traceroute=/usr/sbin/traceroute
[[ -x /sbin/ifconfig ]] && alias ifconfig=/sbin/ifconfig
[[ -x /sbin/route ]] && alias route=/sbin/route
if [ -x /usr/bin/recode ]; then
alias unix2dos='recode lat1..ibmpc'
alias dos2unix='recode ibmpc..lat1'
fi
alias 221='pstops "2:0L@.7(21cm,0)+1L@.7(21cm,14.85cm)"'
alias rot13='tr a-zA-Z n-za-mN-ZA-M'
#alias xlock='ssh-add -D && xlock -mode blank'
#alias 64216="base64-decode | perl -e 'undef \$/; \$a=<>; print unpack(\"H\*\", \$a),\"\n\";'"
alias 64216='perl -MMIME::Base64 -e "print unpack(\"H*\", decode_base64(<>)),\"\n\""'
alias 16264='perl -MMIME::Base64 -e "\$l=<>; chomp \$l; print encode_base64(pack(\"H*\", \$l)),\"\n\""'
alias base64-encode='perl -MMIME::Base64 -e "print encode_base64(<>)"'
alias base64-decode='perl -MMIME::Base64 -e "print decode_base64(<>)"'
alias vnc='xtightvncviewer -encodings "tight copyrect" -compresslevel 9 -quality 4'
alias rdesktop-w='rdesktop -x l -g 1280x1024 -a 16 172.22.118.112'
if [ -f ~/.ssh/alias ] ; then
. ~/.ssh/alias
else
if [ -f ~/.ssh/config ] ; then
for i in `grep "^Host " ~/.ssh/config | awk ' !/\*/ {print $2}'`; do alias $i="ssh $i"; done
fi
fi
if [ "$HOSTNAME" = 'danube' ]; then
alias cfs-attach='cattach -t 20 $HOME/.cfs weasel'
alias send-mail='sudo -u uucp /usr/sbin/uucico -r1 -x3 -f -snautilus.3node.com'
fi
if [ "$HOSTNAME" = 'danubeX.local.' ]; then
alias vi='vim'
fi
if [ "$HOSTNAME" = 'opium' ] || [ "$HOSTNAME" = 'asteria' ]; then
alias ldapvi='ldapvi -h ldap-server -D cn=weasel,ou=admins,ou=staff,o=hosting.noreply.org -w `grep bindpw $HOME/.noreply.ldap | cut -d" " -f 2`'
fi
if [ "$HOSTNAME" = 'thetis' ] ; then
alias ldapvi='ldapvi -h localhost -D cn=admin,o=ab.office.dibral.at -w `grep bindpw $HOME/.noreply.ldap | cut -d" " -f 2`'
fi
if [ "$HOSTNAME" = 'andromeda' ] ; then
alias ldapvi-nonanoymous='ldapvi -h localhost -D uid=weasel,ou=users,ou=accounts,dc=oftc,dc=net -b dc=oftc,dc=net'
fi
if [ "$HOSTNAME" = 'asteria' ] && [ -r "$HOME/.oftc-hosts" ] ; then
cat "$HOME/.oftc-hosts" | while read name ip; do
alias -g $name-ip="$ip"
alias irssi-$name="irssi --home=$HOME/.irssi-MASTER --connect=OFTC-$name"
alias -g $name-testnet-ip="$ip"
alias irssi-testnet-$name="irssi --home=$HOME/.irssi-MASTER --connect=TESTNET-$name"
# irssi-$name () {
# local ip name oftcircport
# name=`echo "$0" | sed -e 's/irssi-//'`
# ip=`awk '$1=="'"$name"'" {print $2}' $HOME/.oftc-hosts`
# if ! [ -d "$HOME/.irssi-$name" ] && [ -e "$HOME/.irssi-MASTER" ]; then
# mkdir "$HOME/.irssi-$name"
# ln -s ../.irssi-MASTER/config $HOME/.irssi-$name/config
# fi
# if ! [ -e "$HOME/.irssi-$name/scripts" ] && [ -e "$HOME/.irssi-MASTER/scripts" ]; then
# ln -s ../.irssi-MASTER/scripts $HOME/.irssi-$name/scripts
# fi
# if [ -e "$HOME/.oftc-port" ]; then
# oftcircport="--port=`cat $HOME/.oftc-port`"
# else
# oftcircport=""
# fi
# irssi --home=$HOME/.irssi-$name --connect=$ip --nick=weasel-$name $oftcircport
# }
# irssi-testnet-$name () {
# local ip name oftcircport
# name=`echo "$0" | sed -e 's/irssi-testnet-//'`
# ip=`awk '$1=="'"$name"'" {print $2}' $HOME/.oftc-hosts`
# if ! [ -d "$HOME/.irssi-testnet-$name" ] && [ -e "$HOME/.irssi-MASTER" ]; then
# mkdir "$HOME/.irssi-testnet-$name"
# ln -s ../.irssi-MASTER/config $HOME/.irssi-testnet-$name/config
# fi
# if ! [ -e "$HOME/.irssi-testnet-$name/scripts" ] && [ -e "$HOME/.irssi-MASTER/scripts" ]; then
# ln -s ../.irssi-MASTER/scripts $HOME/.irssi-testnet-$name/scripts
# fi
# if [ -e "$HOME/.oftc-testnet-port" ]; then
# oftcircport="--port=`cat $HOME/.oftc-port`"
# else
# oftcircport=""
# fi
# irssi --home=$HOME/.irssi-testnet-$name --connect=$ip --nick=weasel-$name $oftcircport
# }
done
fi
if [ -e /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
if [ "`id -u`" = "0" -o ! -x /usr/bin/id ] ; then
export PROMPT="${debian_chroot:+[$debian_chroot] }%n@%m:%~# "
export TITLE="%n@%m: %~"
else
export PROMPT="${debian_chroot:+[$debian_chroot] }%n@%m:%~$ "
export TITLE="%n@%m: %~"
fi
PATH="/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:$PATH"
if [ -d /sw/bin ] ; then
PATH="/sw/bin:${PATH}"
fi
if [ -d $HOME/bin ] ; then
PATH="${HOME}/bin:${PATH}"
fi
if [ -d $HOME/local/bin ] ; then
PATH="${HOME}/local/bin:${PATH}"
fi
if [ -d $HOME/local/amd64/bin ] && [ "$ARCH" = "x86_64" ] ; then
PATH="${HOME}/local/amd64/bin:${PATH}"
fi
if [ -d $HOME/local/i386/bin ] && [ "$ARCH" = "i386" ] ; then
PATH="${HOME}/local/i386/bin:${PATH}"
fi
if [ -d /usr/lib/ccache ] ; then
PATH="/usr/lib/ccache:${PATH}"
elif [ -d /usr/lib/compilercache ] ; then
PATH="/usr/lib/compilercache:${PATH}"
fi
if [ "`id -u`" = "0" ] || ! [ -x /usr/bin/id ] ; then
PATH="/usr/local/sbin:/usr/sbin:/sbin:${PATH}"
fi
typeset -U PATH
MANPATH="/usr/share/man:/usr/local/share/man:/usr/local/man:$MANPATH"
if [ -d $HOME/local/share/man ] ; then
MANPATH="${HOME}/local/share/man:${MANPATH}"
fi
if [ `uname -s` = "Darwin" ] ; then
if [ "$TERM" = "xterm" ]; then
export TERM="xterm-color"
fi
fi
# we want colorful listings
zmodload -i zsh/complist
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
hosts=""
if [ -e $HOME/.ssh/known_hosts ]; then
hosts=(${${${${(f)"$(<$HOME/.ssh/known_hosts)"}:#[0-9]*}%%\ *}%%,*})
zstyle ':completion:*:hosts' hosts $hosts
fi
autoload -U compinit
compinit
##########
cols() {
COLS_awkvar=""
COLS_firstarg=1
[ "$#" -eq 0 ] && { printf "cols: No parameters supplied.\n" >&2; return 1; }
for COLS_arg in "$@"; do
if [ "$COLS_firstarg" -eq 1 ]; then
COLS_awkvar="print \$$COLS_arg"
COLS_firstarg=0
else
COLS_awkvar="$(printf '%s "\t" $%s' "$COLS_awkvar" "$COLS_arg")"
fi
done
awk "{ $COLS_awkvar }"
}
upgrade-porter-chroots() {
cd
for i in `cat ~/.csshrc | grep '^debporterbox' | sed -e 's/^.*=//' | tr ' ' '\n'`; do
mkdir hosts/chroot-$i 2>/dev/null || continue;
echo $i;
preexec $i;
ssh $i -t 'cd ~/chroot &&
for i in */; do
echo;
echo `hostname` $i;
echo;
sudo chroot $i apt-get update &&
sudo chroot $i apt-get dist-upgrade -y &&
sudo chroot $i apt-get clean;
sudo chroot $i apt-get autoremove;
done';
done
}
upgrade-debian-hosts() {
cd
for i in `cat ~/.csshrc | grep '^deb' | sed -e 's/^.*=//' | tr ' ' '\n'`; do
mkdir hosts/$i 2>/dev/null || continue;
echo $i;
preexec $i;
ssh $i -t '
sudo apt-get update &&
sudo apt-get dist-upgrade &&
sudo apt-get clean
';
done
}
upgrade-systems() {
cd
for i in `cat ~/.csshrc | tr ' ' '\n' | grep @`; do
mkdir hosts/$i 2>/dev/null || continue;
echo $i;
preexec $i;
ssh $i -t 'apt-get update &&
if [ -e /usr/bin/apt-get.distrib ]; then
aptitude dist-upgrade;
else
apt-get dist-upgrade;
fi &&
apt-get clean';
done
}
upgrade-came() {
cd
for i in $HOSTS; do
mkdir hosts/$i 2>/dev/null || continue;
echo $i;
preexec $i;
ssh -l root $i -t 'apt-get update &&
if [ -e /usr/bin/apt-get.distrib ]; then
aptitude dist-upgrade;
else
apt-get dist-upgrade;
fi &&
apt-get clean';
done
}
fpr() {
(
ssh-keygen -r '' -f =( ssh-keyscan -t rsa $1 2>/dev/null | sed -e 's/^[^ ]* //');
ssh-keygen -r '' -f =( ssh-keyscan -t dsa $1 2>/dev/null | sed -e 's/^[^ ]* //');
) | sed -e 's/^[^ ]* //'
}
##########
md() {
DIR="$1"
mkdir "$1" && cd "$1"
}
#########
sd() {
fp=$( wget -q -O - http://tor.noreply.org:80/tor/status/authority | \
awk '$1 == "r" && $2 == "'$1'" {printf "%s===", $3}' | \
perl -MMIME::Base64 -e "print unpack(\"H*\", decode_base64(<>)),\"\n\"" )
echo wget -q -O - http://tor.noreply.org:80/tor/server/fp/$fp
}
if [ -x /usr/bin/ddate ] ; then
/usr/bin/ddate
echo
fi
if [ -x /usr/games/fortune ]; then
FORTUNE_PATH=""
[ -d /usr/share/games/fortunes ] && FORTUNE_PATH="$FORTUNE_PATH /usr/share/games/fortunes"
[ -d /usr/share/games/fortunes/off ] && FORTUNE_PATH="$FORTUNE_PATH /usr/share/games/fortunes/off"
[ -d $HOME/.fortunes/ ] && FORTUNE_PATH="$FORTUNE_PATH $HOME/.fortunes/"
fortune `echo $FORTUNE_PATH`
echo
fi
#watch=( $(<~/.friends) ) # watch for people in .friends file
watch=(notme) # watch for everybody but me
LOGCHECK=300 # check every 5 min for login/logout activity
WATCHFMT='%n %a %l from %m at %t.'
[ -f COMMANDMENTS ] && cat COMMANDMENTS
if [ "$SSH_AUTH_SOCK" != "" ] && [ "$SSH_AUTH_SOCK" != "$HOME/.ssh-auth-sock" ] ; then
if ! [ -e "$HOME/.ssh-auth-sock" ] || [ "`readlink $HOME/.ssh-auth-sock`" != "$SSH_AUTH_SOCK" ]; then
echo "Setting ~/.ssh-auth-sock."
rm -f "$HOME/.ssh-auth-sock"
ln -s "$SSH_AUTH_SOCK" "$HOME/.ssh-auth-sock"
fi
elif [ "$SSH_AUTH_SOCK" = "" ] && [ -e "$HOME/.ssh-auth-sock" ]; then
SSH_AUTH_SOCK="$HOME/.ssh-auth-sock"; export SSH_AUTH_SOCK
fi
# Complete sshc as ssh
compdef _ssh sshc=ssh
compdef _ssh cssh=ssh
#alias scp="scp -S $HOME/bin/ssh"
alias hs-mplayer='mplayer -ao alsa:device=hw=1'
[ -e $HOME/.zshrc-local ] && . $HOME/.zshrc-local
[ -e $HOME/.pal ] && [ -e /usr/bin/pal ] && pal -r 5-10
unset LANG
|