added recovery of the terminal title from before ssh resets it, but only works for...
authorChris Koeritz <fred@gruntose.com>
Fri, 30 Jan 2015 00:44:16 +0000 (19:44 -0500)
committerChris Koeritz <fred@gruntose.com>
Fri, 30 Jan 2015 00:44:16 +0000 (19:44 -0500)
customizing/fred/scripts/ssh.sh

index 9bf10d17888de7775dbea40356a7e0713529304f..90b0a56721af9421995d3286fd309f41a3d0ff78 100755 (executable)
@@ -4,6 +4,9 @@
 
 source "$FEISTY_MEOW_GENERATED/custom/scripts/pick_credentials.sh"
 
+# save the former terminal title if we're running in X.
+prior_title="$(xprop -id $WINDOWID | perl -nle 'print $1 if /^WM_NAME.+= \"(.*)\"$/')"
+
 if [ ! -z "$keyfile" ]; then
   \ssh -i "$keyfile" -X -C -c blowfish-cbc $*
 else
@@ -15,7 +18,11 @@ if [ $? -eq 0 ]; then
   if [ -z "$(echo $* | grep git)" ]; then
     # re-run the terminal labeller after coming back from ssh.
     # we check the exit value because we don't want to update this for a failed connection.
-    bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh
+    if [ -z "$prior_title" ]; then
+      bash $FEISTY_MEOW_SCRIPTS/tty/label_terminal_with_infos.sh
+    else
+      bash $FEISTY_MEOW_SCRIPTS/tty/set_term_title.sh "$prior_title"
+    fi
   fi
 fi