diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-06-21 10:44:50 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-06-21 10:46:21 -0700 |
commit | 134984230ac68c0bf5595ffbf4c2b1198b975803 (patch) | |
tree | 7cd2ec475952c69babfa27eaf0a85e743f0f1493 /bin | |
parent | 37cc1fdbc9789e129afc5f3d523240446625463b (diff) | |
download | dotfiles-134984230ac68c0bf5595ffbf4c2b1198b975803.tar.gz |
new ssh-and-tmux and ssh-and-tmux-term and some connecting up
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/debian-ftp-master | 8 | ||||
-rwxr-xr-x | bin/dmenu_ssh | 7 | ||||
-rwxr-xr-x | bin/ssh-and-tmux | 22 | ||||
-rwxr-xr-x | bin/ssh-and-tmux-term | 7 |
4 files changed, 38 insertions, 6 deletions
diff --git a/bin/debian-ftp-master b/bin/debian-ftp-master index 8f454fac..6694ec24 100755 --- a/bin/debian-ftp-master +++ b/bin/debian-ftp-master @@ -57,10 +57,7 @@ ssh ftp-master.debian.org pgrep -u spwhitton emacs \ # sleep 0.3 # done -# have to say the '&' else on buster, command does not exit until -# terminal window is closed -xfce4-terminal --title="ftp-master dak command session" -x /bin/sh \ - -c "ssh -t ftp-master.debian.org tmux new-session -A -s dak" & +ssh-and-tmux-term ftp-master.debian.org dak "ftp-master dak command session" until wmctrl -l | grep -q "ftp-master dak command session"; do sleep 0.3 done @@ -71,8 +68,7 @@ wmctrl -R "ftp-master dak command session" # container on buster's i3 (but not stretch's) i3-msg layout tabbed -xfce4-terminal --title="ftp-master GNU mc session" -x /bin/sh \ - -c "ssh -t ftp-master.debian.org tmux new-session -A -s mc" & +ssh-and-tmux-term ftp-master.debian.org mc "ftp-master GNU mc session" until wmctrl -l | grep -q "ftp-master GNU mc session"; do sleep 0.3 done diff --git a/bin/dmenu_ssh b/bin/dmenu_ssh new file mode 100755 index 00000000..c833166b --- /dev/null +++ b/bin/dmenu_ssh @@ -0,0 +1,7 @@ +#!/bin/sh + +host=$(perl -wlne'/^Host\s+(\S+)/ and !/\*/ and print $1' $HOME/.ssh/config \ + | dmenu -p "ssh to tmux on host" "$@") +if [ -n "$host" ]; then + ssh-and-tmux-term "$host" +fi diff --git a/bin/ssh-and-tmux b/bin/ssh-and-tmux new file mode 100755 index 00000000..0f39558a --- /dev/null +++ b/bin/ssh-and-tmux @@ -0,0 +1,22 @@ +#!/bin/bash + +# when mosh isn't installed on the server, but tmux is, use this to get a +# fairly persistent set of remote shell sessions. I used to use autossh here, +# but that means surprise dialogs asking to authorise use of an SSH key; +# instead, just hit <Ret> to restart a window's connection when it's +# convenient +# +# (The reason that I get prompted is because I have a short +# ServerAliveInterval and low ServerAliveCountMax, but that's desirable, +# because unresponsive SSH sessions are a massive pain) + +host="$1" +session="${2:-default}" +prompt="Press any key to reconnect to tmux session [1m$session[0m on [1m$host[0m; C-c/C-d to give up .." + +while true; do + ssh -t "$host" "tmux new-session -A -s $session" + clear + read -n 1 -r -s -p "$prompt" ch + [ "$ch" = $'\04' ] && exit +done diff --git a/bin/ssh-and-tmux-term b/bin/ssh-and-tmux-term new file mode 100755 index 00000000..682d1a68 --- /dev/null +++ b/bin/ssh-and-tmux-term @@ -0,0 +1,7 @@ +#!/bin/bash + +host="$1" +session="${2:-default}" +title="${3:-tmux $session on $host}" + +xfce4-terminal --title="$title" -x ssh-and-tmux "$host" "$session" |