summaryrefslogtreecommitdiff
path: root/bin/ssh-and-tmux
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-06-21 11:47:07 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-06-21 17:23:18 -0700
commit6ee710e12d13ef8874a4b7b7a2529c0ee7de827c (patch)
treee60cfb234be7180a38d85d8b96078e3a5fc6983a /bin/ssh-and-tmux
parent404afc1f834054bb6a2d8687558d3de804504aed (diff)
downloaddotfiles-6ee710e12d13ef8874a4b7b7a2529c0ee7de827c.tar.gz
ssh-and-tmux: on successful ssh exit, exit script
Diffstat (limited to 'bin/ssh-and-tmux')
-rwxr-xr-xbin/ssh-and-tmux8
1 files changed, 7 insertions, 1 deletions
diff --git a/bin/ssh-and-tmux b/bin/ssh-and-tmux
index 1aca3efc..cd66ecc2 100755
--- a/bin/ssh-and-tmux
+++ b/bin/ssh-and-tmux
@@ -72,12 +72,18 @@ fi
if $use_mosh; then
mosh "$host" -- "${cmd[@]}"
else
+ # The idea behind quitting on d, C-c or C-d was so that the user can type
+ # C-d C-d to kill the remote shell and then kill this script, C-\ d d to
+ # detach tmux and then kill this script, or similar.
+ #
+ # We now die when ssh exits zero, so this feature may be obsolete.
+
echo -ne "\033]0;tmux $session on $display_host\007"
prompt="Press any key to reconnect to tmux session $session on "
prompt+="$display_host; d/C-d/C-c to give up .."
while true; do
- ssh -t "$host" "${cmd[*]}"
+ ssh -t "$host" "${cmd[*]}" && exit
clear
read -n 1 -r -s -p "$prompt" ch
[ "$ch" = $'\04' -o "$ch" = d ] && echo && exit