From 6b58452ff1cfe14cd1fcfb5651634b078341d597 Mon Sep 17 00:00:00 2001 From: Mika Suomalainen Date: Mon, 24 Oct 2011 22:16:41 +0300 Subject: [PATCH] zsh_functions: Copied "ex" from zshrc of bioterror. (Highlight to my IRC channel:) Unit193: Welcome to my zsh_functions :P Also copied full comments, which bioterror had added. Also (what is "omistuskirjoitus" in English) was copied. --- zsh_functions | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/zsh_functions b/zsh_functions index 4713fc5a..d6b40ca2 100644 --- a/zsh_functions +++ b/zsh_functions @@ -53,3 +53,36 @@ function top10() { # copyright 2007 - 2010 Christopher Bratusek history | awk '{a[$2]++ } END{for(i in a){print a[i] " " i}}' | sort -rn | head } + +# ex command. Copied from zshrc of bioterror ( http://ricecows.org/configs/zsh/.zshrc ). Original comment below: +## for unit193 ;) +## use command "ex" to extract any archive files. +## "ex package.zip" for example +function ex () + +{ +if [ -f "$1" ] ; then +case "$1" in + *.tar) tar xvf $1 ;; + *.tar.bz2 | *.tbz2 ) tar xjvf $1 ;; + *.tar.gz | *.tgz ) tar xzvf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *.xz) tar xJvf $1 ;; + *.deb) + DIR=${1%%_*.deb} + ar xv $1 + mkdir ${DIR} + tar -C ${DIR} -xzvf data.tar.gz ;; + *.rpm) rpm2cpio $1 | cpio -vid ;; + *) echo ""${1}" cannot be extracted via extract()" +;; + esac + else + echo ""${1}" is not a valid file" +fi +}