Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Smartly extract files from archives via 'extract'

  • Loading branch information...
commit 571f60a09c0f2804f2cbb3d5d25276e6b192ea94 1 parent 90c88c5
@gabebw authored
Showing with 28 additions and 2 deletions.
  1. +28 −2 zsh/aliases.zsh
View
30 zsh/aliases.zsh
@@ -1,6 +1,8 @@
###########
# ALIASES #
###########
+alias q="vim ~/.zshrc"
+alias qq="source ~/.zshrc"
alias cp="cp -iv"
alias rm="rm -iv"
alias mv="mv -iv"
@@ -40,5 +42,29 @@ function p {
fi
}
-alias q="$EDITOR ~/.zshrc"
-alias qq="source ~/.zshrc"
+# credit: http://nparikh.org/notes/zshrc.txt
+# Usage: extract <file>
+# Description: extracts archived files / mounts disk images
+# Note: .dmg/hdiutil is Mac OS X-specific.
+extract () {
+ if [ -f $1 ]; then
+ case $1 in
+ *.tar.bz2) tar -jxvf $1 ;;
+ *.tar.gz) tar -zxvf $1 ;;
+ *.bz2) bunzip2 $1 ;;
+ *.dmg) hdiutil mount $1 ;;
+ *.gz) gunzip $1 ;;
+ *.tar) tar -xvf $1 ;;
+ *.tbz2) tar -jxvf $1 ;;
+ *.tgz) tar -zxvf $1 ;;
+ *.zip) unzip $1 ;;
+ *.ZIP) unzip $1 ;;
+ *.pax) cat $1 | pax -r ;;
+ *.pax.Z) uncompress $1 --stdout | pax -r ;;
+ *.Z) uncompress $1 ;;
+ *) echo "'$1' cannot be extracted/mounted via extract()" ;;
+ esac
+ else
+ echo "'$1' is not a valid file"
+ fi
+}
Please sign in to comment.
Something went wrong with that request. Please try again.