diff --git a/includes/bash_functions.sh b/includes/bash_functions.sh index be1cbbf..8bc2ba7 100644 --- a/includes/bash_functions.sh +++ b/includes/bash_functions.sh @@ -33,4 +33,27 @@ function unidecode() { function codepoint() { perl -e "use utf8; print sprintf('U+%04X', ord(\"$@\"))" echo # newline -} \ No newline at end of file +} + +# Extract archives of various types +function extract() { + if [ -f $1 ] ; then + local dir_name=${1%.*} # Filename without extension + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.tar.xz) tar Jxvf $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.zip) unzip -d$dir_name $1 ;; + *.Z) uncompress $1 ;; + *) echo "'$1' cannot be extracted via extract()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} diff --git a/setup/brew.sh b/setup/brew.sh index 8f81d52..7af8bc3 100755 --- a/setup/brew.sh +++ b/setup/brew.sh @@ -24,6 +24,7 @@ brew install homebrew/dupes/grep # Install everything else brew install git brew install git-extras +brew install unrar #brew install node # Remove outdated versions from the cellar