✨ Add extract()
This commit is contained in:
parent
545ed249eb
commit
0404784f9f
1 changed files with 45 additions and 0 deletions
45
fish/.config/fish/functions/extract.fish.symlink
Normal file
45
fish/.config/fish/functions/extract.fish.symlink
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/env fish
|
||||||
|
|
||||||
|
# Extracts archived files / mounts disk images.
|
||||||
|
# Usage: extract <file>
|
||||||
|
|
||||||
|
function extract -a file
|
||||||
|
if [ -f "$file" ]
|
||||||
|
switch file
|
||||||
|
case "*.tar.bz2"
|
||||||
|
tar -jxvf $file
|
||||||
|
case "*.tar.gz"
|
||||||
|
tar -zxvf $file
|
||||||
|
case "*.bz2"
|
||||||
|
bunzip2 $file
|
||||||
|
case "*.dmg"
|
||||||
|
if [ "$(uname)" = Darwin ]
|
||||||
|
hdiutil mount $file
|
||||||
|
end
|
||||||
|
case "*.gz"
|
||||||
|
gunzip $file
|
||||||
|
case "*.tar"
|
||||||
|
tar -xvf $file
|
||||||
|
case "*.tbz2"
|
||||||
|
tar -jxvf $file
|
||||||
|
case "*.tgz"
|
||||||
|
tar -zxvf $file
|
||||||
|
case "*.zip"
|
||||||
|
unzip $file
|
||||||
|
case "*.ZIP"
|
||||||
|
unzip $file
|
||||||
|
case "*pax"
|
||||||
|
cat $file | pax -r
|
||||||
|
case "*.pax.Z"
|
||||||
|
uncompress $file --stdout | pax -r
|
||||||
|
case "*.rar"
|
||||||
|
unrar x $file
|
||||||
|
case "*.Z"
|
||||||
|
uncompress $file
|
||||||
|
case "*"
|
||||||
|
echo "'$file' cannot be extracted/mounted via extract()."
|
||||||
|
end
|
||||||
|
else
|
||||||
|
echo "'$file' is not a valid file."
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue