From 60861151b5db379d180b8c2481f604009cac7999 Mon Sep 17 00:00:00 2001 From: Tamas Pal Date: Tue, 8 Jul 2014 10:34:09 +0200 Subject: [PATCH 1/3] base.plugin: simple todo no longer conflicts with todo plugin --- plugins/available/base.plugin.bash | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index ea02bb7b..4f09c515 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -153,7 +153,7 @@ function usage () if [ ! -e $BASH_IT/plugins/enabled/todo.plugin.bash ]; then # if user has installed todo plugin, skip this... - function t () + function __simpletodo () { about 'one thing todo' param 'if not set, display todo item' @@ -164,6 +164,9 @@ if [ ! -e $BASH_IT/plugins/enabled/todo.plugin.bash ]; then echo "$*" > ~/.t fi } + if ! alias | grep -q ' t='; then + alias t=__simpletodo + fi fi function command_exists () From a1e87c49203633c059cb3aa8ca26fec2c7650292 Mon Sep 17 00:00:00 2001 From: Tamas Pal Date: Tue, 8 Jul 2014 11:01:27 +0200 Subject: [PATCH 2/3] base: ips uses ifconfig or ip according to $OSTYPE, supports IPv6 ifconfig not available to users on Linux and it has a different output, using ip instead. Also, added support to show IPv6 addresses too. --- plugins/available/base.plugin.bash | 43 ++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/plugins/available/base.plugin.bash b/plugins/available/base.plugin.bash index 4f09c515..c8ccf574 100644 --- a/plugins/available/base.plugin.bash +++ b/plugins/available/base.plugin.bash @@ -3,11 +3,50 @@ about-plugin 'miscellaneous tools' function ips () { - about 'display all ip addresses for this host' + about 'display all IPv4/6 addresses for this host' group 'base' - ifconfig | grep "inet " | awk '{ print $2 }' + + mode=4 + if [ -n "$1" ]; then + case "$1" in + -4) ;; + -6) mode=6 ;; + -a) mode=both ;; + -h) echo "Usage ips [-4|-6|-a]" + echo " -4 list only IPv4 addresses" + echo " -6 list only IPv6 addresses" + echo " -a list both IPv4 and IPv6 addresses" + return + ;; + *) echo "Illegal option $1" + echo "Only -4, -6 and -a options are allowed" + return 1 + ;; + esac + fi + + token="inet" + case $mode in + 4) ;; + 6) token="${token}6" ;; + both) token="${token}6?" ;; + esac + case "$OSTYPE" in + darwin*) + ifconfig | grep -E "${token} " | awk '{ print $2 }' + ;; + + # ifconfig is not available for users on modern linux distributions, + # also it uses a slightly different format. + # Use ip instead. + linux*) + ip ad | grep -E "${token} " | awk '{ sub(/\/.*$/,"",$2); print $2}' + ;; + esac } +alias ips6='ips -6' + function down4me () { about 'checks whether a website is down for you, or everybody' From 05baab75dde151eaf099862f13a7ee67f5075ff6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20P=C3=A1l?= Date: Sat, 12 Jul 2014 23:33:17 +0200 Subject: [PATCH 3/3] exctract.plugin: added support for multiple compressors Added support for the LZMA, LZOP, XZ and lzip compressors and for the cpio archiver. Now works with files and paths containing whitespaces. --- plugins/available/extract.plugin.bash | 43 ++++++++++++++++++--------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/plugins/available/extract.plugin.bash b/plugins/available/extract.plugin.bash index bb520451..3389f2e0 100644 --- a/plugins/available/extract.plugin.bash +++ b/plugins/available/extract.plugin.bash @@ -6,20 +6,35 @@ extract () { echo "Error: No file specified." return 1 fi - 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 ;; - *.zip) unzip $1 ;; - *.Z) uncompress $1 ;; - *.7z) 7z x $1 ;; - *) echo "'$1' cannot be extracted via extract" ;; + if [ -f "$1" ] ; then + case "$1" in + *.tar.bz2) tar xvjf "$1" ;; + *.tar.gz) tar xvzf "$1" ;; + *.tar.xz|*.txz) + xz -dc "$1" | tar xvf - ;; + *.tar.lzma) ( xz -dc "$1" || lzma -dc "$1" ) | tar xvf - ;; + *.tar.lzop) lzop -d -c "$1" | tar xvf - ;; + *.tar.lzip) lzip -d -c "$1" | tar xvf - ;; + *.cpio.gz|*.cpio.Z) + gzip -dc "$1" | cpio -itvm ;; + *.cpio.bz2) bzip2 -dc "$1" | cpio -itvm ;; + *.cpio.xz) xz -dc "$1" | cpio -itvm ;; + *.cpio) cpio -itvm < "$1" ;; + *.bz2) bunzip2 "$1" ;; + *.rar) unrar x "$1" ;; + *.gz) gunzip "$1" ;; + *.tar) tar xvf "$1" ;; + *.tbz2) tar xvjf "$1" ;; + *.tgz) tar xvzf "$1" ;; + *.zip) unzip "$1" ;; + *.jar) unzip "$1" ;; + *.Z) (uncompress "$1" || gzip -dc "$1") ;; + *.7z) 7z x "$1" ;; + *.lzma) (xz -dc "$1" || lzma -d "$1") ;; + *.lzop) lzop -d "$1" ;; + *.lzip) lzip -d "$1" ;; + *.xz) xz -d "$1" ;; + *) echo "'$1' cannot be extracted via extract" ;; esac else echo "'$1' is not a valid file"