[ssh_tools] tabssh: handle tmux
This commit is contained in:
parent
c661ccd8eb
commit
dbb0d6bf3a
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/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)
|
# (Formerly named cluster-ssh.sh)
|
||||||
#
|
#
|
||||||
# This program is free software. It comes without any warranty, to
|
# This program is free software. It comes without any warranty, to
|
||||||
|
@ -56,9 +56,14 @@ elif [ $# -ne 1 ] ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check dependencies
|
# Check dependencies
|
||||||
SCREEN=$(command -v screen)
|
TMUX_CMD=$(command -v tmux)
|
||||||
if [ -z "$SCREEN" ] ; then
|
SCREEN_CMD=$(command -v screen)
|
||||||
err "GNU screen is required by this script."
|
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
|
exit $EXIT_DEPENDENCY
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -82,6 +87,10 @@ fi
|
||||||
# Create the screen tabs
|
# Create the screen tabs
|
||||||
while read -r HOST ; do
|
while read -r HOST ; do
|
||||||
SSH="ssh ${LOGIN}${HOST}"
|
SSH="ssh ${LOGIN}${HOST}"
|
||||||
# shellcheck disable=SC2086
|
if [ -n "$TMUX_CMD" ] ; then
|
||||||
$SCREEN -t "$SSH" $SSH
|
$TMUX_CMD new-window -d -n "$SSH" -- "$SSH"
|
||||||
|
else
|
||||||
|
# shellcheck disable=SC2086
|
||||||
|
$SCREEN_CMD -t "$SSH" $SSH
|
||||||
|
fi
|
||||||
done <"$HOSTS"
|
done <"$HOSTS"
|
||||||
|
|
Loading…
Reference in New Issue