From 0c9a85a54e7487f7f792af6c296f6f80605b3f38 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Mon, 14 Jan 2013 09:40:54 +0000 Subject: [PATCH] Add a couple of useful aliases --- shell/aliases.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/shell/aliases.sh b/shell/aliases.sh index b2260a6..7717a20 100644 --- a/shell/aliases.sh +++ b/shell/aliases.sh @@ -35,3 +35,32 @@ function authme { ssh "$1" 'mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys' \ < ~/.ssh/id_dsa.pub } + +# Make and cd into directory +# - from: http://alias.sh/make-and-cd-directory +function mcd() { + mkdir -p "$1" && cd "$1"; +} + +# Extract most common archives with single command. +# - from: http://alias.sh/extract-most-know-archives-one-command +function extract () { + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar e $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 +}