Browse code

Added a function to extract various archives. Also an alias for the function.

SuprDewd authored on 24/12/2010 at 22:20:57
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,24 @@ function take() {
37 37
   mkdir -p $1
38 38
   cd $1
39 39
 }
40
+
41
+function extract() {
42
+  if [[ -f $1 ]]; then
43
+    case $1 in
44
+      *.tar.bz2) tar xvjf $1;;
45
+      *.tar.gz) tar xvzf $1;;
46
+      *.bz2) bunzip $1;;
47
+      *.rar) unrar $1;;
48
+      *.gz) gunzip $1;;
49
+      *.tar) tar xvf $1;;
50
+      *.tbz2) tar xvjf $1;;
51
+      *.tgz) tar xvzf $1;;
52
+      *.zip) unzip $1;;
53
+      *.Z) uncompress $1;;
54
+      *.7z) 7z x $1;;
55
+      *) echo "'$1' cannot be extracted via >extract<";;
56
+    esac
57
+  else
58
+    echo "'$1' is not a valid file"
59
+  fi
60
+}