summaryrefslogtreecommitdiff
path: root/etc/functions/extract
blob: 53fdc87059a8c54acb36137e6eee326a8ac468ca (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
## vim:ft=zsh
## Extract archives
## Usage: extr <file>

if [[ -f ${1} ]] {
	case ${1} in
		*.tar*) tar xvf ${*} ;;
		*.ace) unace e ${1} ;;
		*.rar) unrar x ${1} ;;
		*.deb) ar -x ${1} ;;
		*.bz2) bunzip2 ${1} ;;
		*.lzh) lha x ${1} ;;
		*.gz) gunzip ${1} ;;
		*.tar) tar xvf ${*} ;;
		*.zip) unzip ${1} ;;
		*.Z) uncompress ${1} ;;
		*.cpio) cpio --no-absolute-filenames -idv < ${1} ;;
		*.lzma) unlzma ${1} ;;
		*) echo "Unknown archive type: ${1}"; return 2 ;;
	esac
} else {
	echo "No such file: ${1}"
	return 1
}