Now, here is a simple function for extracting archives depending on their file type.
I did not write this function myself and all credit goes to Vincent, Milomouse.
# extract archive with preferred options:
function extr {
if [[ -f $1 ]]; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*.xz) unxz -vk $1 ;;
*.lzma) unlzma -vk $1 ;;
*) print "'$1' cannot be extracted via extr()" ;;
esac
else
print "'$1' is not a valid file"
fi
}
Add the following to your .zshrc to be able to use the function:
(Don't forget to replace '.zsh' and 'funcs' with your own dir/filename)
# source external configuration files:
ZDOTDIR="${HOME}/.zsh"
for i in ${ZDOTDIR}/funcs; do
. $i || { print "$i: cannnot source file" }
done
All done! Whenever you wish to extract an archive just type "extr /path/to/archive" without the quotes ofcourse.