mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-03 15:40:32 +00:00
Plugin to expand or extract bundled & compressed files [finishes #90]
This commit is contained in:
parent
e2325053f2
commit
ac6610df4e
25
plugins/extract/extract.fish
Normal file
25
plugins/extract/extract.fish
Normal file
@ -0,0 +1,25 @@
|
||||
# Taken from: https://github.com/dideler/dotfiles/blob/master/functions/extract.fish
|
||||
|
||||
function extract --description "Expand or extract bundled & compressed files"
|
||||
set --local ext (echo $argv[1] | awk -F. '{print $NF}')
|
||||
switch $ext
|
||||
case tar # non-compressed, just bundled
|
||||
tar -xvf $argv[1]
|
||||
case gz
|
||||
if test (echo $argv[1] | awk -F. '{print $(NF-1)}') = tar # tar bundle compressed with gzip
|
||||
tar -zxvf $argv[1]
|
||||
else # single gzip
|
||||
gunzip $argv[1]
|
||||
end
|
||||
case tgz # same as tar.gz
|
||||
tar -zxvf $argv[1]
|
||||
case bz2 # tar compressed with bzip2
|
||||
tar -jxvf $argv[1]
|
||||
case rar
|
||||
unrar x $argv[1]
|
||||
case zip
|
||||
unzip $argv[1]
|
||||
case '*'
|
||||
echo "unknown extension"
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user