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; [
babelfish
gnutar
bzip2
bzip3
gzip
unzip
pax
unrar-free
];
programs.fish = {
@ -36,29 +43,68 @@
'';
shellAbbrs = {
cp = {
position = "command";
expansion = "cp -iv";
};
cp = "cp -iv";
mkdir = "mkdir -pv";
mv = "mv -iv";
rm = "rm -r";
grep = "grep --color=auto";
};
mkdir = {
position = "command";
expansion = "mkdir -pv";
};
functions = {
extract = {
argumentNames = "file";
body = # fish
''
set --erase argv[1]
mv = {
position = "command";
expansion = "mv -iv";
};
if test -f "$file"
switch "$file"
case "*.tar.bz2"
tar -jxvf $argv $file
rm = {
position = "command";
expansion = "rm -r";
};
case "*.tar.gz"
tar -zxvf $argv $file
grep = {
position = "command";
expansion = "grep --color=auto";
case "*.bz2"
bunzip2 $argv $file
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
'';
};
};
};