1 # Author: Copyright © 2005 Eric P. Mangold - teratorn (-at-) gmail (-dot) com
2 # License: MIT. http://www.opensource.org/licenses/mit-license.html
3 # http://zshwiki.org/home/examples/functions
5 local old_dirs current_dirs lower
8 if [[ $lower == *.tar.gz || $lower == *.tgz ]]; then
10 elif [[ $lower == *.gz ]]; then
12 elif [[ $lower == *.tar.bz2 || $lower == *.tbz ]]; then
13 bunzip2 -c $1 | tar xfv -
14 elif [[ $lower == *.bz2 ]]; then
16 elif [[ $lower == *.zip ]]; then
18 elif [[ $lower == *.rar ]]; then
20 elif [[ $lower == *.tar ]]; then
22 elif [[ $lower == *.lha ]]; then
25 print "Unknown archive type: $1"
28 # Change in to the newly created directory, and
29 # list the directory contents, if there is one.
30 current_dirs=( *(N/) )
31 for i in {1..${#current_dirs}}; do
32 if [[ $current_dirs[$i] != $old_dirs[$i] ]]; then
39 #compdef '_files -g "*.gz *.tgz *.bz2 *.tbz *.zip *.rar *.tar *.lha"' extract_archive