From b4ed85e08b31d353a1644d1c8b963c3f2d43f2c5 Mon Sep 17 00:00:00 2001 From: David Runge Date: Fri, 18 Apr 2014 16:51:17 +0200 Subject: Cleaning up functions, adding tar_xz --- .zsh.after/functions.zsh | 71 ++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/.zsh.after/functions.zsh b/.zsh.after/functions.zsh index 5dc5943..ceaf909 100644 --- a/.zsh.after/functions.zsh +++ b/.zsh.after/functions.zsh @@ -154,7 +154,7 @@ function publish() { mute pushd $DIR scp $FILE pool:public_html/ echo "http://www-pool.math.tu-berlin.de/~runge/$FILE" - echo "http://www-pool.math.tu-berlin.de/~runge/$FILE"|xcp + echo "http://www-pool.math.tu-berlin.de/~runge/$FILE"|cpx mute popd } @@ -170,31 +170,44 @@ refresh() { } +## compress stuff +tar_tgz() { + tar cvfz $1.tgz $1 +} +tar_tbz() { + tar cvfj $1.tbz $1 +} +tar_tlz() { + tar --lzma -cvf $1.tlz $1 +} +tar_xz() { + tar cf - $1| xz -4e > $1.tar.xz +} #Decompress any given compressed file -extract () { +ex() { if [ -f $1 ] ; then -case $1 in - *.tar.bz2) tar xvjf $1 ;; - *.tar.gz) tar xvzf $1 ;; - *.bz2) bunzip2 $1 ;; - *.rar) unrar x $1 ;; - *.gz) gunzip $1 ;; - *.tar) tar xvf $1 ;; - *.tbz2) tar xvjf $1 ;; - *.tgz) tar xvzf $1 ;; - *.xz) tar xvJf $1 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1 ;; - *.7z) 7z x $1 ;; - *) echo "don't know how to extract '$1'..." ;; -esac + case $1 in + *.tar.bz2) tar xvjf $1 ;; + *.tar.gz) tar xvzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xvf $1 ;; + *.tbz2) tar xvjf $1 ;; + *.tgz) tar xvzf $1 ;; + *.xz) tar xvJf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "don't know how to extract '$1'..." ;; + esac else -echo "'$1' is not a valid file!" + echo "'$1' is not a valid file!" fi } -extract_to() { +ex2() { if [ -f $2 ] ;then echo "Extracting to '$2'" local out = $2 @@ -209,19 +222,11 @@ extract_to() { fi } -## compress stuff -function tar_tgz { - tar cvfz $1.tgz $1 -} -function tar_tbz { - tar cvfj $1.tbz $1 -} -function tar_tlz { - tar --lzma -cvf $1.tlz $1 -} + + ##CRYPTSETUP AND LUKS -function lopen () { +lopen() { case $HOST in "homey") case $1 in @@ -265,7 +270,7 @@ function lopen () { fi } -function lclose () { +lclose() { notmounted=$(mountpoint /mnt/$1) if [ "$?" -eq 0 ]; then #stop services blocking the umount @@ -285,12 +290,12 @@ function lclose () { ## RSYNC -function backupinfo () { +backupinfo() { rsync -r -n -t -p -o -g -v --progress --delete --ignore-existing --size-only -s --exclude 'lost+found' --exclude '.Trash-1000' --exclude '$RECYCLEBIN' --exclude 'System Volume Information' --exclude '.thumbs' $1 $2 echo "rsync -r -n -t -p -o -g -v --progress --delete --ignore-existing --size-only -s --exclude 'lost+found' --exclude '.Trash-1000' --exclude '\$RECYCLEBIN' --exclude 'System Volume Information' --exclude '.thumbs' /path/to/folder/ /path/to/other/folder" } -function backupfolder () { +backupfolder() { rsync -r -t -p -o -g -v --progress --delete --ignore-existing --size-only -s --exclude 'lost+found' --exclude '.Trash-1000' --exclude '$RECYCLEBIN' --exclude 'System Volume Information' --exclude '.thumbs' $1 $2 } -- cgit v1.2.3-70-g09d2