aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-07-21 14:41:40 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-07-21 14:41:40 -0300
commita29c439c8f412270799951384f9b8c18c485bc45 (patch)
treead9c8352a56645cc72c829d7f77db1123f32f76c
parent2e23f385dc9610f92d8ac57d5b584cbb92eedc4d (diff)
downloadscripts-a29c439c8f412270799951384f9b8c18c485bc45.tar.gz
scripts-a29c439c8f412270799951384f9b8c18c485bc45.tar.bz2
Setting window title inside screen
-rwxr-xr-xshell19
1 files changed, 19 insertions, 0 deletions
diff --git a/shell b/shell
index 5111518..e2a48c1 100755
--- 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