]> git.nbdom.net Git - nb.git/commitdiff
shell functions
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 8 Jul 2015 10:34:38 +0000 (11:34 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 8 Jul 2015 10:34:38 +0000 (11:34 +0100)
etc/bashrc.function
etc/profile.d/nb.sh

index f63517693b2de45949e5643e5bd618556491f15d..bc1eb0abaaf202b40fe7d9bfdd08ffa99caec522 100644 (file)
@@ -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"`
index 095608f5fa68776b3cf7c20ddaaa7e250cc36793..65f6898b8b80071e75a453c66bf17de6dba8a3e9 100644 (file)
@@ -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