2012-05-18 13:09:58 +04:00
|
|
|
#!/bin/zsh
|
|
|
|
# vim: set filetype=zsh
|
|
|
|
|
|
|
|
cdl() { cd $1 && ls }
|
|
|
|
|
|
|
|
mkcd() { mkdir $1 && cd $1 }
|
|
|
|
|
|
|
|
rcd() { cd .. && rm -irfv $OLDPWD }
|
|
|
|
|
|
|
|
extract () {
|
2012-06-06 11:53:04 +04:00
|
|
|
if [ $2 ] ; then
|
|
|
|
echo "too many parameters to extract ()"
|
|
|
|
elif [ -f "$1" ] ; then
|
|
|
|
case $1 in
|
2012-06-06 12:15:41 +04:00
|
|
|
*.tar.bz2|*.tbz2|*.tbz) which lbunzip2 &>/dev/null \
|
|
|
|
&& lbunzip2 -c -kn$((`grep "^processor" /proc/cpuinfo -c`+1)) $1 | tar xf - \
|
|
|
|
|| tar xjf $1 ;;
|
2012-06-06 11:53:04 +04:00
|
|
|
*.tar.gz|*.tgz) tar xzf $1 ;;
|
|
|
|
*.tar.xz|*.txz) tar xJf $1 ;;
|
|
|
|
*.tar) tar xf $1 ;;
|
|
|
|
*.bz2) which lbunzip2 &>/dev/null \
|
|
|
|
&& lbunzip2 -kn$((`grep "^processor" /proc/cpuinfo -c`+1)) $1 \
|
2012-06-06 12:37:47 +04:00
|
|
|
|| bunzip2 -k $1 ;;
|
|
|
|
*.gz) gunzip -c $1 > ${1%.gz} || rm -f ${1%.gz} ;;
|
|
|
|
*.xz) unxz -k $1 ;;
|
2012-06-06 12:03:30 +04:00
|
|
|
*.rar) unrar x $1 ;;
|
2012-06-06 11:53:04 +04:00
|
|
|
*.zip) unzip $1 ;;
|
2012-06-06 12:15:41 +04:00
|
|
|
#*.Z) uncompress $1 ;;
|
2012-06-06 11:53:04 +04:00
|
|
|
*.7z) 7z x $1 ;;
|
|
|
|
*) echo "I don't know how to extract '$1'..." ;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
echo "'$1' is not a valid file"
|
|
|
|
echo "Usage: extract file"
|
|
|
|
fi
|
2012-05-18 13:09:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pk () {
|
2012-06-06 11:53:04 +04:00
|
|
|
if [ $3 ] ; then
|
|
|
|
echo "too many parameters to pk ()"
|
|
|
|
elif [ $1 ] ; then
|
|
|
|
case $1 in
|
2012-06-06 12:37:47 +04:00
|
|
|
t*b*z*) tar cjvf $2.tar.bz2 $2 ;;
|
2012-06-06 11:53:04 +04:00
|
|
|
t*g*z) tar czvf $2.tar.gz $2 ;;
|
|
|
|
t*x*|t*J*) tar cJvf $2.tar.xz $2 ;;
|
|
|
|
t*r) tar cpvf $2.tar $2 ;;
|
|
|
|
b*z*) which lbzip2 &>/dev/null \
|
|
|
|
&& lbzip2 -9 -kn$((`grep "^processor" /proc/cpuinfo -c`+1)) $2 \
|
2012-06-06 12:37:47 +04:00
|
|
|
|| bzip2 -9 -k $2 ;;
|
|
|
|
g*z) gzip -c -9 -n $2 > $2.gz || rm -f $2.gz ;;
|
|
|
|
x*z) xz -k -9 $2 ;;
|
2012-06-06 14:35:58 +04:00
|
|
|
rar) rar a $2.rar $2 -m5 -ol ;;
|
2012-06-06 14:31:56 +04:00
|
|
|
zip) zip -9 --symlinks -r $2.zip $2 ;;
|
2012-06-06 12:15:41 +04:00
|
|
|
#Z) ;;
|
2012-06-06 11:53:04 +04:00
|
|
|
7z) 7z -mx=9 a $2.7z $2 ;;
|
|
|
|
*) echo "'$1' cannot be packed via pk()" ;;
|
|
|
|
esac
|
|
|
|
else
|
|
|
|
echo "Usage: pk tbz file"
|
|
|
|
fi
|
2012-05-18 13:09:58 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
calc() {
|
|
|
|
echo $* | bc
|
|
|
|
}
|
|
|
|
|
|
|
|
vcs_info_wrapper() {
|
|
|
|
vcs_info
|
|
|
|
if [ -n "$vcs_info_msg_0_" ]; then
|
|
|
|
echo "%{$fg[grey]%}${vcs_info_msg_0_}%{$reset_color%}$del"
|
|
|
|
fi
|
|
|
|
}
|