Skip to content

Instantly share code, notes, and snippets.

@steewbsd
Last active September 21, 2020 10:08
Show Gist options
  • Save steewbsd/337bf7135fd7b4d3a0ae702d07dc35f8 to your computer and use it in GitHub Desktop.
Save steewbsd/337bf7135fd7b4d3a0ae702d07dc35f8 to your computer and use it in GitHub Desktop.
Quick fish function to extract generic compressed archives. Usage: extract [FILE]. Add this to your ~/.config/fish/functions folder
function extract
if test $argv && test -e $argv
switch $argv
case '*.tar.bz2'
tar xjf $argv
case '*.tar.gz'
tar xzf $argv
case "*.bz2"
bunzip2 $argv
case "*.rar"
unar x $argv
case "*.gz"
gunzip $argv
case "*.tar"
tar xf $argv
case "*.tbz2"
tar xjf $argv
case "*.tgz"
tar xzf $argv
case "*.zip"
unzip $argv
case "*.Z"
uncompress $argv
case "*.7z"
7z x $argv
case "*.deb"
ar x $argv
case "*.tar.xz"
tar xf $argv
case '*'
echo "Could not determine file type or cannot be extracted"
end
else
echo "No file provided"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment