]> gitweb.fluxo.info Git - scripts.git/commitdiff
Setting window title inside screen
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 21 Jul 2014 17:41:40 +0000 (14:41 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 21 Jul 2014 17:41:40 +0000 (14:41 -0300)
shell

diff --git a/shell b/shell
index 5111518d7a13013ca1d14d85b30e51505b138b90..e2a48c13981c4bbc3f72d33fafba35b5f1b7d0ae 100755 (executable)
--- a/shell
+++ b/shell
@@ -3,14 +3,28 @@
 # Simple autossh and screen wrapper.
 #
 
+# Parameters
 BASENAME="`basename $0`"
 DEST="$1"
 COMMAND="$2"
 
+# Set screen title
+# http://stackoverflow.com/questions/899609/gnu-screen-run-script-that-sends-commands-to-the-screen-session-it-is-being-run
+function screen_title {
+  if [ -n "$STY" ]; then
+    screen -X title $1
+  fi
+}
+
+# Syntax check
 if [ -z "$DEST" ]; then
   exit 1
 fi
 
+# Set default screen title
+screen_title $DEST
+
+# Dispatcher
 if [ "$BASENAME" == "shells" ]; then
   # Remote screen shell using autossh
   if [ "$COMMAND" == "root" ]; then
@@ -24,12 +38,17 @@ else
     wscreen $DEST
   elif [ -z "$COMMAND" ] && [ "$DEST" == "root" ]; then
     # Local root shell
+    screen_title root
     sudo screen -x
   elif [ "$DEST" == "local" ]; then
     # Local screen shell
+    screen_title $COMMAND
     wscreen $COMMAND
   else
     # Remote shell using autossh
     autossh $DEST -t -- $COMMAND
   fi
 fi
+
+# Restore screen title
+screen_title terminal