forked from Belgarion/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaliases
467 lines (431 loc) · 13.4 KB
/
aliases
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
#!/bin/bash
UNAMES=`uname -s`
konsole-title() {
if [ $KONSOLE_DCOP_SESSION ]; then
if [[ "$@" == "" ]]; then
dcop $KONSOLE_DCOP_SESSION sessionName
else
dcop $KONSOLE_DCOP_SESSION renameSession "$@"
fi
fi
}
screen-title() { echo -ne '\ek'$@'\e\\'; }
alias screen_cmd='screen -d -r ${STY} -X '
#alias screen='TERM=xterm-256color screen' #causes problems with terminfo on resume
ssh() {
if [ $KONSOLE_DCOP_SESSION ]; then
#local NAME="`dcop $KONSOLE_DCOP_SESSION sessionName`" || NAME="`basename $SHELL`"
local NAME="`konsole-title`" || NAME="`basename $SHELL`"
konsole-title $1
elif [ $STY ] || [ $TMUX ]; then
local NAME="`basename $SHELL`"
screen-title $1
fi
if [ $ZSH_VERSION ]; then `whence -p ssh` $@;
else `which ssh` $@;
fi
if [ $KONSOLE_DCOP_SESSION ]; then konsole-title "$NAME";
elif [ $STY ] || [ $TMUX ]; then screen-title "$NAME";
fi
}
alias ssh-x='ssh -c arcfour,blowfish-cbc -XC'
aklog-ltu() {
if [[ $# -le 0 ]]; then
print "Usage: $0 <username>"
return 1
fi
KRB5CCNAME=/tmp/krb5cc_${UID}ltu
kinit [email protected]
aklog -d ltu.se
}
if [[ $UNAMES == "FreeBSD" ]]; then
alias dfh='df -hc -t nounionfs,nullfs '
alias dfhl='df -hcl -t nounionfs,nullfs '
elif [[ $(df --version | head -1 | sed 's/.*\([0-9]\).[0-9]\+/\1/') -ge 8 ]]; then
alias dfh='df -h -x none -x tmpfs -x usbfs -x aufs -x squashfs -x rootfs -x devpts --total '
alias dfhl='df -l -h -x none -x tmpfs -x usbfs -x aufs -x squashfs -x rootfs -x devpts --total '
else
dfh() {
if (type calc &>/dev/null) && (type dc &>/dev/null); then
local val=0
local total=0
local used=0
local free=0
local IFS=$'\n'
df -h -x none -x tmpfs -x usbfs -x aufs -x squashfs \
-x rootfs -x devpts $@
for i in `df -P -k -x none -x tmpfs -x usbfs -x aufs -x squashfs \
-x rootfs -x devpts $@ | grep -v "ftp://" | sed '1d'`
do
val=$[`echo -n $i|awk '{print $2}'`]
total=$[$total+$val]
val=$[`echo -n $i|awk '{print $3}'`]
used=$[$used+$val]
val=$[`echo -n $i|awk '{print $4}'`]
free=$[$free+$val]
done
echo -------------------------------------------------------
totalb=$total
usedb=$used
freeb=$free
totalPostfix="K"
totalDecimals=0
usedPostfix="K"
usedDecimals=0
freePostfix="K"
freeDecimals=0
while [[ $total -gt 1024 ]]; do
total=`dc <<< "5k $total 1024/p"`
case $totalPostfix in
K) totalPostfix="M";;
M) totalPostfix="G";;
G) totalPostfix="T";;
*) totalPostfix="*";;
esac
[[ $total -lt 10 ]] && totalDecimals=1
done
while [[ $used -gt 1024 ]]; do
used=`dc <<< "5k $used 1024/p"`
case $usedPostfix in
K) usedPostfix="M";;
M) usedPostfix="G";;
G) usedPostfix="T";;
*) usedPostfix="*";;
esac
[[ $used -lt 10 ]] && usedDecimals=1
done
while [[ $free -gt 1024 ]]; do
free=`dc <<< "5k $free 1024/p"`
case $freePostfix in
K) freePostfix="M";;
M) freePostfix="G";;
G) freePostfix="T";;
*) freePostfix="*";;
esac
[[ $free -lt 10 ]] && freeDecimals=1
done
printf "* "
printf "%3.*f%s %3.*f%s %3.*f%s %2d%% Total\n" \
$totalDecimals $total $totalPostfix \
$usedDecimals $used $usedPostfix \
$freeDecimals $free $freePostfix \
`calc -p "round(($usedb/$totalb)*100)"`
else
echo "Install calc and dc"
df -h -x none -x tmpfs -x usbfs -x aufs -x squashfs -x rootfs $@
fi
}
dfhl() {
# like dfh(), but only local filesystems
if (type calc &>/dev/null); then
local val=0
local total=0
local used=0
local free=0
local IFS=$'\n'
df -l -h -x none -x tmpfs -x usbfs -x aufs -x squashfs \
-x rootfs -x devpts $@
for i in `df -l -P -k -x none -x tmpfs -x usbfs -x aufs -x \
squashfs -x rootfs -x devpts $@ | grep -v "ftp://" | sed '1d'`
do
val=$[`echo -n $i|awk '{print $2}'`]
total=$[$total+$val]
val=$[`echo -n $i|awk '{print $3}'`]
used=$[$used+$val]
val=$[`echo -n $i|awk '{print $4}'`]
free=$[$free+$val]
done
echo -------------------------------------------------------
totalb=$total
usedb=$used
freeb=$free
totalPostfix="K"
totalDecimals=0
usedPostfix="K"
usedDecimals=0
freePostfix="K"
freeDecimals=0
while [[ $total -gt 1024 ]]; do
total=`dc <<< "5k $total 1024/p"`
case $totalPostfix in
K) totalPostfix="M";;
M) totalPostfix="G";;
G) totalPostfix="T";;
*) totalPostfix="*";;
esac
[[ $total -lt 10 ]] && totalDecimals=1
done
while [[ $used -gt 1024 ]]; do
used=`dc <<< "5k $used 1024/p"`
case $usedPostfix in
K) usedPostfix="M";;
M) usedPostfix="G";;
G) usedPostfix="T";;
*) usedPostfix="*";;
esac
[[ $used -lt 10 ]] && usedDecimals=1
done
while [[ $free -gt 1024 ]]; do
free=`dc <<< "5k $free 1024/p"`
case $freePostfix in
K) freePostfix="M";;
M) freePostfix="G";;
G) freePostfix="T";;
*) freePostfix="*";;
esac
[[ $free -lt 10 ]] && freeDecimals=1
done
printf "* "
printf "%3.*f%s %3.*f%s %3.*f%s %2d%% Total\n" \
$totalDecimals $total $totalPostfix \
$usedDecimals $used $usedPostfix \
$freeDecimals $free $freePostfix \
`calc -p "round(($usedb/$totalb)*100)"`
else
echo "Install calc"
df -l -h -x none -x tmpfs -x usbfs -x aufs -x squashfs -x rootfs $@
fi
}
fi
alias cd..='cd ..'
alias rm='rm -i'
alias mv='mv -i'
alias tmux="tmux -2" # force 256-colors
(type vim >&/dev/null) && [ $('vim' --version |head -1|sed 's/.*\([0-9]\)\.[0-9].*/\1/') -ge 7 ] && alias vim='vim -p'
alias icl2ico='wrestool -x --output=. -t14'
alias ico2png='for i in *.ico; do convert "$i" "$i.png"; done'
alias sfv='cksfv -f'
alias grep='grep --color=auto'
(type yafc >&/dev/null) && alias ftp='yafc'
alias samdump='bkhive2 system syskey.txt && samdump2 SAM syskey.txt'
alias ifstat='ifstat -S'
(type htop >&/dev/null) && alias top='htop'
alias man='LC_ALL=C LANG=C man'
alias extract_initrd_here='zcat /initrd.img | cpio -i -d -H newc --no-absolute-filenames'
alias mplayer='mplayer -slang eng -af volnorm'
mplayer_rar() { unrar p -inul $1 | mplayer -af volnorm - ; }
mplayer_dvd() { mplayer -af volnorm -dvd-device "$1" dvd:// ; }
alias wine='XMODIFIER="" XMODIFIERS="" wine'
alias dm7020_path='export PATH=/opt/dm7020/bin:$PATH'
alias du='du -c'
alias fix_directory_permissions='find . -type d -exec sudo chmod ugo+x {} \;'
alias nmap='nmap -A -T insane'
alias mplayer_spdif='mplayer -ao alsa:device=spdif'
alias scpresume='rsync --partial --progress --rsh=ssh'
alias rm_thumbs.db='find . -iname thumbs.db -exec rm {} \;'
alias psa='ps -ALf'
alias rsync-cont='rsync -rlptDv --append'
alias rsync='rsync --progress'
alias info='pinfo'
alias mouseacc='xset m 9/8 10'
alias rdesktop='rdesktop -r sound'
alias vacuum_firefox='for i in ~/.mozilla/firefox/*/*.sqlite; do echo "VACUUM;" | sqlite3 $i ; done'
upload_terminfo() {
infocmp | ssh $1 'dd of=term.terminfo; tic -C term.terminfo | sed "\$s/$/AF=\\\\E[3%dm:AB=\\\\E[4%dm:/" >> .termcap; rm -f term.terminfo'
}
upload_termcap() {
infocmp | ssh $1 'dd of=term.terminfo; tic -o .terminfo/ term.terminfo; rm -f term.terminfo'
}
# Colored output start
if (type grc >&/dev/null); then
alias cl='grc -es --colour=auto'
alias configure='cl ./configure'
alias diff='cl diff'
alias make='cl make'
alias gcc='cl gcc'
alias g++='cl g++'
alias as='cl as'
alias gas='cl gas'
alias ld='cl ld'
alias netstat='cl netstat'
alias ping='cl ping'
alias ping6='cl ping6'
alias traceroute='cl traceroute'
alias last='cl last'
ctail() { if (echo $PWD|grep log >&/dev/null); then grc -es -c conf.log tail $@; else grc -es tail $@; fi; }
ccat() { if (echo $PWD|grep log >&/dev/null); then grc -es -c conf.log cat $@; elif [ `echo $@|grep "\.cpp$\|\.h$\|\.c$"` ]; then spc $@; else grc -es cat $@; fi; }
alias tail='ctail'
alias cat='ccat'
fi
# Color end
confirm() {
echo -n "$@ "
read -r choice
case "$choice" in
y|Y) return 0;;
*) return 1;;
esac
}
luddprint() {
if [[ $# -le 0 ]]; then
print "Usage: $0 <filename>"
return 1
fi
if confirm "Are you sure you want to print '$1' to Edison.ludd? [y/n]"; then
echo "Printing file '$1' on Edison"
cat $1 | ssh orac.ludd.ltu.se lpr -P Edison
fi
}
upre() {
echo -n "uptime: `uptime | sed 's/.*up \(.*\),.*user.*/\1/'` :: record: "
if [[ "$UNAMES" == "FreeBSD" ]]; then
uprecords -asm1 | gsed 's/|.*//g;s/\(->\|\s\)\s*1\s*//;;s/ //g' | gawk 'NR==3 {print $LN}'
else
uprecords -asm1 | sed 's/|.*//g;s/\(->\|\s\)\s*1\s*//;;s/ //g' | gawk 'NR==3 {print $LN}'
fi
}
mod2ogg() { xmp -d wav -c $1 |sox -v1.5 -t wav - -t wav - |oggenc -o ${1%.*}.ogg -; }
mid2wav() { timidity $1 -Ow --output-stereo -o $1.wav; }
isomount() { sudo mount -t iso9660 -o loop $1 /mnt/cdrom; }
ranpasswd() {
if [[ $1 -gt 0 ]]; then
local length="$1"
local count="$2"
local x=$(($length+10))
local y=$(($x-10))
for i in `seq 1 $count`; do
head -c $[$length*2] /dev/random | uuencode -m - | sed -n 2p | head -c $y
echo
done
else
echo "ranpasswd <length> [count]"
fi
}
if [[ "$UNAMES" == "FreeBSD" ]]; then
alias poweroff="shutdown -p now"
if [[ -f /usr/local/bin/gnuls ]]; then
if [ $CFORCE ]; then
eval `env TERM="vt100" dircolors -b /etc/DIR_COLORS 2> /dev/null`
else
eval `dircolors -b /etc/DIR_COLORS 2> /dev/null`
fi
alias ls="/usr/local/bin/gnuls --color=auto -F"
else
LSCOLORS="ExGxCxDxBxDxDxCxCxExEx"; export LSCOLORS
alias ls="ls -G -F"
fi
elif [[ "$UNAMES" == "Linux" || "${UNAMES%_*}" == "CYGWIN" ]]; then
if [[ "$UNAMES" == "Linux" ]]; then
alias poweroff="shutdown -h now"
fi
# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
if [ -f ~/.DIR_COLORS ]; then
eval "`dircolors -b ~/.DIR_COLORS`"
elif [ -f /etc/DIR_COLORS ]; then
eval "`dircolors -b /etc/DIR_COLORS`"
else
eval "`dircolors -b`"
fi
alias ls='ls --color=auto --ignore="lost+found" -F'
alias dir='ls --color=auto --format=vertical'
alias vdir='ls --color=auto --format=long'
fi
elif [[ "$UNAMES" == "OpenBSD" || "$UNAMES" == "NetBSD" ]]; then
alias poweroff="shutdown -hp now"
if [[ -f /usr/local/bin/gls && "$UNAMES" == "OpenBSD" ]]; then
eval `dircolors -b /etc/DIR_COLORS 2> /dev/null`
alias ls="/usr/local/bin/gls --color=auto -F"
fi
if [[ "$UNAMES" == "NetBSD" ]]; then
if [[ -f /usr/pkg/bin/linuxls ]]; then
eval `dircolors -b /etc/DIR_COLORS ~ 2> /dev/null`
alias ls='/usr/pkg/bin/linuxls --color=tty -F'
elif [[ -f /usr/pkg/bin/colorls ]]; then
LSCOLORS="ExGxCxDxBxDxDxCxCxExEx"; export LSCOLORS
alias ls="/usr/pkg/bin/colorls -G -F"
fi
fi
elif [[ "$UNAMES" == "Darwin" ]]; then
alias poweroff="poweroff-compat"
poweroff-compat()
{
if [[ "$1" == "-yes" ]]; then
shutdown -h now
else
echo "Use 'shutdown -yes' if you really mean it, " \
"if you are using OS X this can damage " \
"your files or your entire home folder !!!"
fi
}
if [[ -f /bin/cls ]]; then
alias ls="/bin/cls --color=auto -F"
else
if [[ `uname -r | awk -F '.' '{print $1}'` -ge "7" ]]; then
# to fix vim in aterm, do not forget to add to .Xdefaults:
# aterm*backspacekey: ^H (only in rooted mode !)
# aterm*colorBD: white
LSCOLORS="ExGxCxDxBxDxDxCxCxExEx"; export LSCOLORS
alias ls="ls -G -F"
fi
fi
elif [[ "$UNAMES" == "SunOS" ]]; then
[[ -e /usr/sfw/bin/ggrep ]] && alias grep="/usr/sfw/bin/ggrep --color=auto"
fi
alias l='ls -CF'
alias la='ls -A'
alias la.='ls -Ad .*'
alias ll='ls -l'
alias ll.='ls -ld .*'
#Gentoo specific
#edep() { for i in /usr/portage/*/*/*.ebuild; do grep -H "DEPEND.*$1" $i; done; }
alias esearch='esearch -S'
edep() { for i in /var/db/pkg/*/*/*DEPEND; do grep -H "$1" $i; done; }
pc(){ local i=0; while read; do ((i++)); done < <(printf "%s\n" /var/db/pkg/*/*/); echo "$i"; }
pl(){ local i; for i in /var/db/pkg/*/*; do i="${i#/*/*/*/}"; echo "${i%-[0-9]*}"; done; }
eview() {
FILE=$(equery which $1)
if [ -f "$FILE" ]; then
view $FILE
fi
}
#End Gentoo specific
# Travelmate 800
ledon() { echo "Setting mail led light on"; echo 1 >| /proc/driver/acerhk/led; }
ledoff() { echo "Setting mail led light off"; echo 0 >| /proc/driver/acerhk/led; }
##################################################################################
##
## _bashish_prompt_cwd is a prompt helper
##
## it provides the current working directory with:
## * colored directory delimiters
## * homedir replaced by homedir
## * directory cutoff for a specified length
##
## USAGE:
## _bashish_prompt_cwd [SEPCOLOR] [TXTCOLOR] [CUTOFF]
##
## SEPCOLOR is the escape sequence for setting the directory separator color
## TXTCOLOR is the escape sequence for setting the directory text color
## CUTOFF is the amount of characters to print before cutting the directory
##
##################################################################################
## chop off element by element and replace with "..." if not enough space
if [ ! $ZSH_VERSION ]; then
alias rar='time rar'
alias tar='time tar'
alias emerge='time emerge'
function _bashish_prompt_cwd
{
typeset CWD="" DIR="" IFS=: PWD="$(pwd)" CWD="" IFS INT_MAX=9223372036854775807 SEPCOLOR=${1} TXTCOLOR=${2} CUTOFF=${3:-$INT_MAX}
if test "x$COLUMNS" = x
then
IFS=" "
for COLUMNS in $(stty size);do :;done
unset IFS
fi
eval "case \"$PWD\" in "$HOME"*) PWD=\${PWD:"${#HOME}"};CWD=\$TXTCOLOR\~;;/)CWD=\$SEPCOLOR/;esac"
test $(( $COLUMNS - ${#PWD} )) -lt ${CUTOFF} && {
CWD=${TXTCOLOR}...
eval "PWD=\"\${PWD:$(( ${#PWD} - ( $COLUMNS - $CUTOFF ) ))}\""
}
IFS=/
for DIR in $PWD
do
CWD="$CWD${TXTCOLOR}$DIR${SEPCOLOR}/"
done
unset IFS
printf "${CWD%/}"
}
fi
alias kismet='TERM=rxvt kismet'