Hacker News new | ask | show | jobs
by shpx 2913 days ago
If you have tmux or your remote machine, you can add this alias to your mac's bashrc

    alias my-server='ssh server-hostname -t "tmux new-session -s user || tmux attach-session -t user"'
It will connect to a tmux session on the remote machine if it exists or start a new one if it doesn't. If you Cmd+w your terminal window or disconnect, the tmux session stays running on the remote machine.

You could also tell it to try reconnecting every second and bind it to something easy to type like 'kj' (too bad df is already taken)

    alias kj='while true; do my-server; sleep 1; done'