all repos

dotfiles @ 170e4a6f6ae60b5560d53ad5a2fb4c6823696326

my dotfiles

bin/ex (view raw)

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
26
27
#!/usr/bin/env bash

ex() {
  file=$1
  [ -z "$file" ] && echo 'ex <compressed>' && return 1
  [ ! -f "$file" ] && echo 'Invalid file: `'"$file"'`' && return 1
  case "$file" in
  *.tar.bz2) tar xjf "$file" ;;
  *.tar.gz) tar xzf "$file" ;;
  *.bz2) bunzip2 "$file" ;;
  *.rar) unrar x "$file" ;;
  *.gz) gunzip "$file" ;;
  *.tar) tar xf "$file" ;;
  *.tbz2) tar xjf "$file" ;;
  *.tgz) tar xzf "$file" ;;
  *.zip) unzip "$file" ;;
  *.Z) uncompress "$file" ;;
  *.7z) 7z x "$file" ;;
  *.xz) unxz "$file" ;;
  *)
    echo 'Unknown suffix on file: `'"$file"'`'
    return 1
    ;;
  esac
}

ex "$@"