Browse code

Merge branch 'master' of https://github.com/SuprDewd/oh-my-zsh into SuprDewd-master

Robby Russell authored on 15/01/2011 at 09:17:29
Showing 2 changed files
... ...
@@ -21,3 +21,5 @@ alias ll='ls -l'
21 21
 alias sl=ls # often screw this up
22 22
 
23 23
 alias afind='ack-grep -il'
24
+
25
+alias x=extract
... ...
@@ -37,3 +37,39 @@ function take() {
37 37
   mkdir -p $1
38 38
   cd $1
39 39
 }
40
+
41
+function extract() {
42
+    unset REMOVE_ARCHIVE
43
+    
44
+    if test "$1" = "-r"; then
45
+        REMOVE=1
46
+        shift
47
+    fi
48
+  if [[ -f $1 ]]; then
49
+    case $1 in
50
+      *.tar.bz2) tar xvjf $1;;
51
+      *.tar.gz) tar xvzf $1;;
52
+      *.tar.xz) tar xvJf $1;;
53
+      *.tar.lzma) tar --lzma -xvf $1;;
54
+      *.bz2) bunzip $1;;
55
+      *.rar) unrar $1;;
56
+      *.gz) gunzip $1;;
57
+      *.tar) tar xvf $1;;
58
+      *.tbz2) tar xvjf $1;;
59
+      *.tgz) tar xvzf $1;;
60
+      *.zip) unzip $1;;
61
+      *.Z) uncompress $1;;
62
+      *.7z) 7z x $1;;
63
+      *) echo "'$1' cannot be extracted via >extract<";;
64
+    esac
65
+
66
+    if [[ $REMOVE_ARCHIVE -eq 1 ]]; then
67
+        echo removing "$1";
68
+        /bin/rm "$1";
69
+    fi
70
+
71
+  else
72
+    echo "'$1' is not a valid file"
73
+  fi
74
+}
75
+