Added extract function for files

This commit is contained in:
Phil 2021-10-29 18:19:20 +01:00
parent 51d376c2ba
commit 53b6a91adb

View File

@ -188,6 +188,31 @@ else
pfdecrypt() {
cat "$1" | sed -e '1d' -e '$d' | base64 -d | openssl enc -d -aes-256-cbc -md md5 -out "$2" -k "$3"
}
# Extract Function
extract() {
if [ ! -f "$1" ];
then
printf '"%s" is not a valid file.' "$1"
exit 1
fi
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" ;;
*.deb) ar x "$1" ;;
*.tar.xz) tar xf "$1" ;;
*) printf 'cannot extract "%s" with extract()' "$1" ;;
esac
}
# Terminal Settings
# set a fancy prompt (non-color, unless we know we "want" color)