3 # Some aliases to make it easier to deal with archives
5 if command -v tar &> /dev/null;
9 [ -d "$1" ] || { echo "usage: gztar <dir> [tar options]" 1>&2; exit 1; }
12 tar "$@" -czvf "$(basename "$DIR").tar.gz" "$DIR"
17 [ -d "$1" ] || { echo "usage: bztar <dir> [tar options]" 1>&2; exit 1; }
20 tar "$@" -cjvf "$(basename "$DIR").tar.bz2" "$DIR"
25 [ -d "$1" ] || { echo "usage: xztar <dir> [tar options]" 1>&2; exit 1; }
28 tar "$@" -cJvf "$(basename "$DIR").tar.xz" "$DIR"
34 # the 'a' options detects the compression from the file name
35 # http://petereisentraut.blogspot.it/2012/05/time-to-retrain-fingers.html
43 complete -o default -f -X '!*.?(t)bz2' bzuntar
44 complete -o default -f -X '!*.@(Z|gz|tgz|Gz|dz)' gzuntar
45 complete -o dirnames gztar bztar
48 if command -v unzip &> /dev/null;
50 # Unzip files into a directory names as the zip file basename
55 DIRNAME="$(basename "$FILENAME" .zip)"
58 [ -d "$DIRNAME" ] && { echo "destination exists!"; return 1; }
59 mkdir "$DIRNAME" && unzip "$@" -d "$DIRNAME" "$FILENAME"
62 complete -o default -f -X '!*.@(zip|ZIP)' dunzip