From dec54d66582adcb3ecfe94572ebf1479bd75ff5f Mon Sep 17 00:00:00 2001 From: Shikiryu Date: Fri, 3 Jun 2016 12:50:55 +0200 Subject: [PATCH] Ajoute des fonctions bien cool --- .bash_aliases | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/.bash_aliases b/.bash_aliases index f7b3948..f295342 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -18,4 +18,50 @@ xmlpretty() { local FILENAME=${ORIGINAL%.xml} local FINAL=${FILENAME##*/} xmllint --format "$1" --output ${FINAL}.pretty.xml -} \ No newline at end of file +} + +function extract() +{ + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xvjf $1 ;; + *.tar.gz) tar xvzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xvf $1 ;; + *.tbz2) tar xvjf $1 ;; + *.tgz) tar xvzf $1 ;; +://codepad.canhelpme.com/nabled=true + *.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 +} + +# Creates an archive (*.tar.gz) from given directory. +function maketar() { tar cvzf "${1%%/}.tar.gz" "${1%%/}/"; } + +# Create a ZIP archive of a file or folder. +function makezip() { zip -r "${1%%/}.zip" "$1" ; } + +function my_ps() { ps $@ -u $USER -o pid,%cpu,%mem,bsdtime,command ; } +function pp() { my_ps f | awk '!/awk/ && $0~var' var=${1:-".*"} ; } + +function dataurl() +{ + local mimeType=$(file -b --mime-type "$1") + if [[ $mimeType == text/* ]]; then + mimeType="${mimeType};charset=utf-8" + fi + echo "data:${mimeType};base64,$(openssl base64 -in "$1" | tr -d '\n')" +} + +shopt -s cdspell # autocorrects cd misspellings +shopt -s checkwinsize # update the value of LINES and COLUMNS after each command if altered + +date