feat(fish): Add extract()

This commit is contained in:
punkfairie 2024-11-05 19:42:31 -08:00
parent ffb1d56723
commit f3c7582486
Signed by: punkfairie
GPG key ID: 01823C057725C266

View file

@ -2,6 +2,13 @@
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
babelfish babelfish
gnutar
bzip2
bzip3
gzip
unzip
pax
unrar-free
]; ];
programs.fish = { programs.fish = {
@ -36,29 +43,68 @@
''; '';
shellAbbrs = { shellAbbrs = {
cp = { cp = "cp -iv";
position = "command"; mkdir = "mkdir -pv";
expansion = "cp -iv"; mv = "mv -iv";
}; rm = "rm -r";
grep = "grep --color=auto";
};
mkdir = { functions = {
position = "command"; extract = {
expansion = "mkdir -pv"; argumentNames = "file";
}; body = # fish
''
set --erase argv[1]
mv = { if test -f "$file"
position = "command"; switch "$file"
expansion = "mv -iv"; case "*.tar.bz2"
}; tar -jxvf $argv $file
rm = { case "*.tar.gz"
position = "command"; tar -zxvf $argv $file
expansion = "rm -r";
};
grep = { case "*.bz2"
position = "command"; bunzip2 $argv $file
expansion = "grep --color=auto";
case "*.bz3"
bunzip3 $argv $file
case "*.gz"
gunzip $argv $file
case "*.tar"
tar -xvf $argv $file
case "*.tbz2"
tar -jxvf $argv $file
case "*.tgz"
tar -zxvf $argv $file
case "*.zip" "*.ZIP"
unzip $argv $file
case "*pax"
cat $file | pax -r $argv
case "*.pax.Z"
uncompress $file --stdout | pax -r $argv
case "*.rar"
unrar-free $file
case "*.Z"
uncompress $argv $file
case "*"
echo "'$file' cannot be extracted via extract()."
end
else
echo "'$file' is not a valid file."
end
'';
}; };
}; };
}; };