#!/bin/bash set -e; . /usr/local/lib/err; set +e remote=$1 fastcon=0 while true; do start=$EPOCHSECONDS # -n or else it competes with the other ssh for reading stdin. ssh -n $remote prof-tail | prof-notify & ssh -t $remote screen -Dr -S profanity ||: builtin kill %% &> /dev/null ||: if (( EPOCHSECONDS > start + 600 )); then fastcon=0 fi # we try to reconnect quickly for a while (just once as I write this), # then try to reconnect slowly. if (( fastcon < 1 )); then echo "waiting 10. any key to cancel" read -rsN1 -t 10 ||: fastcon=$((fastcon+1)) else echo "waiting 120. any key to cancel" # like sleep but stop on any input read -rsN1 -t 120 ||: fi done