aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-08-25 08:04:40 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-08-25 08:04:40 -0300
commit9251d79ccfafcec99beea6ef1d253d299d1980df (patch)
treeae6d256fe43f27e07c8b0968b2fe18a8961a3e94
parent5553760f97821ba88fc9fe01771a2a7df6fd829a (diff)
downloadtermplex-9251d79ccfafcec99beea6ef1d253d299d1980df.tar.gz
termplex-9251d79ccfafcec99beea6ef1d253d299d1980df.tar.bz2
Start tmux migration
-rwxr-xr-xshell28
1 files changed, 20 insertions, 8 deletions
diff --git a/shell b/shell
index f07f854..31d2823 100755
--- a/shell
+++ b/shell
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Simple $AUTOSSH and screen wrapper.
+# Simple $AUTOSSH and terminal multiplexer wrapper.
#
# Parameters
@@ -11,7 +11,9 @@
BASENAME="`basename $0`"
DEST="$1"
COMMAND="$2"
-MULTIPLEXER="wscreen"
+#LOCAL_MULTIPLEXER="wscreen"
+LOCAL_MULTIPLEXER="wtmux"
+REMOTE_MULTIPLEXER="screen -x"
MONITORING="-M $(($RANDOM + 1024))"
AUTOSSH="autossh $MONITORING"
@@ -27,6 +29,16 @@ function window_title {
fi
}
+# Check if a named session exists, screen version
+function shell_wscreen_ls {
+ screen -ls $1 | grep -q "There is a screen on"
+}
+
+# Check if a named session exists, tmux version
+function shell_wtmux_ls {
+ tmux ls | grep -q ^$1:
+}
+
# Syntax check
if [ -z "$DEST" ]; then
exit 1
@@ -39,18 +51,18 @@ window_title $DEST
if [ "$BASENAME" == "shells" ]; then
# Remote screen shell using $AUTOSSH
if [ "$COMMAND" == "root" ]; then
- $AUTOSSH $DEST -t -- sudo screen -x
+ $AUTOSSH $DEST -t -- sudo $REMOTE_MULTIPLEXER
else
- $AUTOSSH $DEST -t -- screen -x $COMMAND
+ $AUTOSSH $DEST -t -- $REMOTE_MULTIPLEXER $COMMAND
fi
else
- if [ -z "$COMMAND" ] && screen -ls $DEST | grep -q "There is a screen on"; then
+ if [ -z "$COMMAND" ] && shell_${LOCAL_MULTIPLEXER}_ls $DEST; then
# Local existing screen shell
- $MULTIPLEXER $DEST
+ $LOCAL_MULTIPLEXER $DEST
elif [ -z "$COMMAND" ] && [ "$DEST" == "root" ]; then
# Local root shell
window_title root
- sudo screen -x
+ sudo $REMOTE_MULTIPLEXER
elif [ -z "$COMMAND" ] && [ -f "$HOME/.screen/$DEST" ]; then
# Local root shell
window_title $DEST
@@ -58,7 +70,7 @@ else
elif [ "$DEST" == "local" ]; then
# Local screen shell
window_title $COMMAND
- $MULTIPLEXER $COMMAND
+ $LOCAL_MULTIPLEXER $COMMAND
else
# Remote shell using $AUTOSSH
$AUTOSSH $DEST -t -- $COMMAND