pull/309/merge
Pál Tamás 2014-08-05 20:13:11 +00:00
commit 48b82304f9
2 changed files with 74 additions and 17 deletions

View File

@ -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'
@ -153,7 +192,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 +203,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 ()

View File

@ -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"