aboutsummaryrefslogtreecommitdiff
path: root/functions/uz.fish
blob: 16111575ee1f9a85b1fe81b6f46c0b75aa5f4c3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function uz --description "Decompress an archive without making a mess"

if test (count $argv) -lt 1
  echo "Missing argument."
  return 1
end

if not check_install 'bsdtar' 'libarchive'
  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