Skip to content

Commit

Permalink
Merge pull request paulirish#7 from christianv/extract
Browse files Browse the repository at this point in the history
extract() archives - the #html5devconf challenge
  • Loading branch information
paulirish committed Oct 17, 2012
2 parents 7beea29 + 26f18fd commit de331d4
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .functions
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,26 @@ function unidecode() {
perl -e "binmode(STDOUT, ':utf8'); print \"$@\""
echo # newline
}

# Extract archives - use: extract <file>
# Credits to http://dotfiles.org/~pseup/.bashrc
function extract() {
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) rar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1 ;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via extract()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}

0 comments on commit de331d4

Please sign in to comment.