zshrc/functions
2010-12-05 17:16:44 +01:00

42 lines
1 KiB
Plaintext

# @author Sebastian Tramp <mail@sebastian.tramp.name>
# @license http://opensource.org/licenses/gpl-license.php
#
# functions and key bindings to that functions
#
# strg+x,s adds sudo to the line
# Zsh Buch p.159 - http://zshbuch.org/
run-with-sudo() { LBUFFER="sudo $LBUFFER" }
zle -N run-with-sudo
bindkey '^Xs' run-with-sudo
# Top ten memory hogs
# http://www.commandlinefu.com/commands/view/7139/top-ten-memory-hogs
memtop() {ps -eorss,args | sort -nr | pr -TW$COLUMNS | head}
zle -N memtop
# Escape potential tarbombs
# http://www.commandlinefu.com/commands/view/6824/escape-potential-tarbombs
atb() {
l=$(tar tf $1);
if [ $(echo "$l" | wc -l) -eq $(echo "$l" | grep $(echo "$l" | head -n1) | wc -l) ];
then tar xf $1;
else mkdir ${1%.t(ar.gz||ar.bz2||gz||bz||ar)} && tar xvf $1 -C ${1%.t(ar.gz||ar.bz2||gz||bz||ar)};
fi ;
}
# reloads all functions
# http://www.zsh.org/mla/users/2002/msg00232.html
r() {
local f
f=(~/.zsh/functions.d/*(.))
unfunction $f:t 2> /dev/null
autoload -U $f:t
}
# activates zmv
autoload zmv