[ssh_tools] tabssh: handle tmux

This commit is contained in:
Matteo Cypriani 2019-10-22 10:36:28 +02:00
父節點 c661ccd8eb
當前提交 dbb0d6bf3a
共有 1 個檔案被更改,包括 15 行新增6 行删除

查看文件

@ -1,6 +1,6 @@
#!/bin/sh
#
# tabssh.sh, Copyright © 2013 Matteo Cypriani <mcy@lm7.fr>
# tabssh.sh, Copyright © 2013, 2019 Matteo Cypriani <mcy@lm7.fr>
# (Formerly named cluster-ssh.sh)
#
# This program is free software. It comes without any warranty, to
@ -56,9 +56,14 @@ elif [ $# -ne 1 ] ; then
fi
# Check dependencies
SCREEN=$(command -v screen)
if [ -z "$SCREEN" ] ; then
err "GNU screen is required by this script."
TMUX_CMD=$(command -v tmux)
SCREEN_CMD=$(command -v screen)
if [ -n "$TMUX_CMD" ] ; then
echo "tmux is available, we'll be using it."
elif [ -n "$SCREEN_CMD" ] ; then
echo "tmux is not available, we'll be using GNU screen instead."
else
err "Either tmux or GNU screen is required by this script."
exit $EXIT_DEPENDENCY
fi
@ -82,6 +87,10 @@ fi
# Create the screen tabs
while read -r HOST ; do
SSH="ssh ${LOGIN}${HOST}"
# shellcheck disable=SC2086
$SCREEN -t "$SSH" $SSH
if [ -n "$TMUX_CMD" ] ; then
$TMUX_CMD new-window -d -n "$SSH" -- "$SSH"
else
# shellcheck disable=SC2086
$SCREEN_CMD -t "$SSH" $SSH
fi
done <"$HOSTS"