diff options
| -rw-r--r-- | conf.d/05z.fish | 11 | ||||
| -rw-r--r-- | functions/7za.fish | 15 | ||||
| -rw-r--r-- | functions/uz.fish | 26 |
3 files changed, 43 insertions, 9 deletions
diff --git a/conf.d/05z.fish b/conf.d/05z.fish index 13ae65a..e370331 100644 --- a/conf.d/05z.fish +++ b/conf.d/05z.fish @@ -1,17 +1,10 @@ if status is-interactive if command -sq bsdtar - alias uz 'bsdtar -xf' alias mz 'bsdtar -a -cf' - if not command -sq unrar - alias unrar 'bsdtar -xf' - end - - if not command -sq 7za - alias 7za 'bsdtar -xf' - end - + alias_if_not unzip bsdtar -xf + alias_if_not unrar bsdtar -xf end # If we have more than one CPU core, use threaded uncompression. diff --git a/functions/7za.fish b/functions/7za.fish new file mode 100644 index 0000000..21b514a --- /dev/null +++ b/functions/7za.fish @@ -0,0 +1,15 @@ +function 7za --wraps 'bsdtar' --description "Emulate 7za with bsdtar" + +if test (count $argv) -lt 1 + echo "Missing argument." + return 1 +end + +if not command -sq bsdtar + echo "Can't fint bsdtar." + return 1 +end + +command bsdtar -xf "$argv[-1]" + +end diff --git a/functions/uz.fish b/functions/uz.fish new file mode 100644 index 0000000..b23780f --- /dev/null +++ b/functions/uz.fish @@ -0,0 +1,26 @@ +function uz --description "Decompress an archive without making a mess" + +if test (count $argv) -lt 1 + echo "Missing argument." + return 1 +end + +if not command -sq bsdtar + echo "Can't fint bsdtar." + return 1 +end + +for archive in $argv + set -l dir (string split '.' "$archive")[1] + if not test -d "$dir" + mkdir "$dir" + pushd "$dir" + command bsdtar -xf ../"$archive" + popd + else + echo "Can't overwrite existing directory." + end +end + +end + |
