From 0e9e12ca7424b5d736cad5350f1a6d46777255c3 Mon Sep 17 00:00:00 2001 From: Corrado Primier Date: Sat, 10 Nov 2018 18:47:44 +0000 Subject: [PATCH] ssh_to: connect to a remote tmux via mosh --- bin/ssh_to | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 bin/ssh_to diff --git a/bin/ssh_to b/bin/ssh_to new file mode 100755 index 0000000..4d86544 --- /dev/null +++ b/bin/ssh_to @@ -0,0 +1,27 @@ +#!/bin/bash +# Connect to a remote tmux session with mosh, avoiding involuntary nesting +# +# This script is not intended to be run by itself. To use it, set up a link +# to it in your path for each server you want to connect to. The link name +# will be used as an ssh destination, so it has to be either a hostname or +# an alias definet in your ~/.ssh/config. + +if [[ ! -h $0 ]] ; then + echo "Error: this script should never be called directly" + exit 1 +fi + +if [[ $# != 0 ]] ; then + echo "Error: this scripts takes no pris^H^H^H^Hparameters" + exit 1 +fi + +MOSH=`command -v mosh` +HOST=${0##/*/} + +if [[ ! -z $TMUX ]] ; then + echo "Error: tmux session detected, aborting to avoid tmux nesting" + exit 1 +fi + +"${MOSH}" -- "${HOST}" tmux a