From 53b6a91adb80e2a838efef388933b0057b6ecd06 Mon Sep 17 00:00:00 2001 From: Phil Date: Fri, 29 Oct 2021 18:19:20 +0100 Subject: [PATCH] Added extract function for files --- .bash_aliases | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.bash_aliases b/.bash_aliases index d1b0222..6bbcda8 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -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)