From dba3675c18873369cd799e8d82118b061fdd6a5f Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Wed, 8 Jul 2015 11:34:38 +0100 Subject: [PATCH] shell functions --- etc/bashrc.function | 4 ++++ etc/profile.d/nb.sh | 6 +----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/etc/bashrc.function b/etc/bashrc.function index f6351769..bc1eb0ab 100644 --- a/etc/bashrc.function +++ b/etc/bashrc.function @@ -7,6 +7,10 @@ shell_functions() { set | perl -ne '/^([\w_-]+) \(\)\s*$/ and print "$1\n"' } +ips() { + ifconfig | perl -ne '/^\s*inet (?:addr:)?([\d\.]+)/ and $1 ne "127.0.0.1" and print "$1\n"' +} + env_add_path() { # Add paths to a variables # Usage PATH=`env_add_path "$PATH" "/blbabla"` diff --git a/etc/profile.d/nb.sh b/etc/profile.d/nb.sh index 095608f5..65f6898b 100644 --- a/etc/profile.d/nb.sh +++ b/etc/profile.d/nb.sh @@ -119,7 +119,7 @@ nb_alert() { local ip=`dig +short $host` [ -z "$ip" ] && echo "Can't resolve macbook.brighton.loc" && return 1 - nb_ips | grep -qxFm1 "$ip" || cmd="ssh -o BatchMode=yes $host -- $cmd" + ips | grep -qxFm1 "$ip" || cmd="ssh -o BatchMode=yes $host -- $cmd" #[ "$USER" != "nico" ] && cmd="su - nico -c '$cmd'" [ "$USER" != "nico" ] && cmd="sudo -u nico -- $cmd" @@ -131,10 +131,6 @@ nb_alert() { eval "$cmd" } -nb_ips() { - ifconfig | perl -ne '/^\s*inet (?:addr:)?([\d\.]+)/ and $1 ne "127.0.0.1" and print "$1\n"' -} - nb_radio_play() { local radios="\ 1 | FranceInter | http://www.tv-radio.com/station/france_inter_mp3/france_inter_mp3-128k.m3u -- 2.47.3