Merge 05baab75dd into e0c48b1637
commit
48b82304f9
|
|
@ -3,11 +3,50 @@ about-plugin 'miscellaneous tools'
|
||||||
|
|
||||||
function ips ()
|
function ips ()
|
||||||
{
|
{
|
||||||
about 'display all ip addresses for this host'
|
about 'display all IPv4/6 addresses for this host'
|
||||||
group 'base'
|
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 ()
|
function down4me ()
|
||||||
{
|
{
|
||||||
about 'checks whether a website is down for you, or everybody'
|
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 [ ! -e $BASH_IT/plugins/enabled/todo.plugin.bash ]; then
|
||||||
# if user has installed todo plugin, skip this...
|
# if user has installed todo plugin, skip this...
|
||||||
function t ()
|
function __simpletodo ()
|
||||||
{
|
{
|
||||||
about 'one thing todo'
|
about 'one thing todo'
|
||||||
param 'if not set, display todo item'
|
param 'if not set, display todo item'
|
||||||
|
|
@ -164,6 +203,9 @@ if [ ! -e $BASH_IT/plugins/enabled/todo.plugin.bash ]; then
|
||||||
echo "$*" > ~/.t
|
echo "$*" > ~/.t
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
if ! alias | grep -q ' t='; then
|
||||||
|
alias t=__simpletodo
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function command_exists ()
|
function command_exists ()
|
||||||
|
|
|
||||||
|
|
@ -6,19 +6,34 @@ extract () {
|
||||||
echo "Error: No file specified."
|
echo "Error: No file specified."
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if [ -f $1 ] ; then
|
if [ -f "$1" ] ; then
|
||||||
case $1 in
|
case "$1" in
|
||||||
*.tar.bz2) tar xvjf $1 ;;
|
*.tar.bz2) tar xvjf "$1" ;;
|
||||||
*.tar.gz) tar xvzf $1 ;;
|
*.tar.gz) tar xvzf "$1" ;;
|
||||||
*.bz2) bunzip2 $1 ;;
|
*.tar.xz|*.txz)
|
||||||
*.rar) unrar x $1 ;;
|
xz -dc "$1" | tar xvf - ;;
|
||||||
*.gz) gunzip $1 ;;
|
*.tar.lzma) ( xz -dc "$1" || lzma -dc "$1" ) | tar xvf - ;;
|
||||||
*.tar) tar xvf $1 ;;
|
*.tar.lzop) lzop -d -c "$1" | tar xvf - ;;
|
||||||
*.tbz2) tar xvjf $1 ;;
|
*.tar.lzip) lzip -d -c "$1" | tar xvf - ;;
|
||||||
*.tgz) tar xvzf $1 ;;
|
*.cpio.gz|*.cpio.Z)
|
||||||
*.zip) unzip $1 ;;
|
gzip -dc "$1" | cpio -itvm ;;
|
||||||
*.Z) uncompress $1 ;;
|
*.cpio.bz2) bzip2 -dc "$1" | cpio -itvm ;;
|
||||||
*.7z) 7z x $1 ;;
|
*.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" ;;
|
*) echo "'$1' cannot be extracted via extract" ;;
|
||||||
esac
|
esac
|
||||||
else
|
else
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue