1

Is there any way I could trigger a bash script when ssh times out?

I have an alias to set the tmux title when starting ssh. The alias also includes a title change after the ssh session, which works if I do a clean exit, but if the session times out, the rest of the alias doesn't run.

3

Wrap ssh with a shell script instead of an alias:

 #!/bin/sh
 echo "Setting up tmux and stuff..."
 # set up tmux and stuff

 ssh "$@"

 echo "Cleaning up..."
 # clean up
  • The only thing, it's not great with nested ssh connections. Otherwise it works perfect. – rush Sep 6 '13 at 13:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.