]> git.nbdom.net Git - nb.git/commitdiff
shell functions
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 8 Jul 2015 13:26:48 +0000 (14:26 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Wed, 8 Jul 2015 13:26:48 +0000 (14:26 +0100)
etc/bashrc
etc/bashrc.function

index 87fa72bab0dbe53eb8d9c1e70cf0a2ae6a3375e0..4c3170f2050eab761acd2258a9342a9099674ef3 100644 (file)
@@ -4,7 +4,7 @@
 #
 #################################################################################
 case "$BASH_SOURCE" in */*) path="${BASH_SOURCE%/*}";; *) path='.' ;; esac
-. "$path/bashrc.function"
+[ -e "$path/bashrc.function" ] && . "$path/bashrc.function"
 NB_ROOT=$(realpath ${path}/..)
 unset path
 
index bc1eb0abaaf202b40fe7d9bfdd08ffa99caec522..86167de60daba3becf07e16b32fb83c97d6f83fa 100644 (file)
@@ -4,7 +4,24 @@
 #
 #################################################################################
 shell_functions() {
-  set | perl -ne '/^([\w_-]+) \(\)\s*$/ and print "$1\n"'
+  set | perl -ne '/^([a-z][\w_-]+) \(\)\s*$/ and print "$1\n"'
+}
+
+shell_slogin() {
+  declare server; server="$1"; shift
+  declare tmp; tmp="/tmp/$FUNCNAME.$USER"
+  (
+    alias
+    type $(shell_functions) | grep -v 'is a function$'
+    cat $NB_ROOT/etc/bashrc
+  ) | ssh "$server" "cat > $tmp || rm -vf $tmp" || return
+
+  declare args
+  if [ -z "$@" ]; then
+    slogin -qt "$server" "bash --rcfile $tmp && rm -f $tmp"
+  else
+    slogin -qt "$server" "bash && rm -f $tmp" <<< ". $tmp; $@"
+  fi
 }
 
 ips() {