65 lines
1.9 KiB
Plaintext
65 lines
1.9 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
|
|
|
|
tmuxhglog() {
|
|
tmux kill-pane -t 1
|
|
tmux split-window -h -l 40 "while true; do clear; date; echo; hg xlog-small -l 5 || exit; sleep 600; done;"
|
|
tmux select-pane -t 0
|
|
}
|
|
|
|
# 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 ;
|
|
}
|
|
|
|
# http://www.commandlinefu.com/commands/view/4792/a-function-to-find-the-newest-file-in-a-directory
|
|
newest () { find ${1:-\.} -type f |xargs ls -lrt ; }
|
|
|
|
# http://www.commandlinefu.com/commands/view/7294/backup-a-file-with-a-date-time-stamp
|
|
buf () {
|
|
oldname=$1;
|
|
if [ "$oldname" != "" ]; then
|
|
datepart=$(date +%Y-%m-%d);
|
|
firstpart=`echo $oldname | cut -d "." -f 1`;
|
|
newname=`echo $oldname | sed s/$firstpart/$firstpart.$datepart/`;
|
|
cp ${oldname} ${newname};
|
|
fi
|
|
}
|
|
|
|
atomtitles () { curl --silent $1 | xmlstarlet sel -N atom="http://www.w3.org/2005/Atom" -t -m /atom:feed/atom:entry -v atom:title -n}
|
|
|
|
|
|
# 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
|
|
# noglob so you don't need to quote the arguments of zmv
|
|
# mmv *.JPG *.jpg
|
|
alias mmv='noglob zmv -W'
|