0

I connect to an SSH server which often disconnects and I have multiple terminal/tabs open in MobaXterm, but I guess this could apply to any terminal client. When the connection breaks it's a disaster because I have to reconnect each terminal and go back to the remote path that I was using, huge waste of time.

MobaXterm provides a handy shortcut (R) to reconnect but that only bring me back to my home directory. Is there anyway that when at reconnect the previous path is restored? It doesn't seem to complicated to implement but I don't see any option to do so in MobaXterm, but maybe there's something that can be done with bash or ssh? Like a script or some ssh setting.

I don't have any control on the server side outside of my own profile.

Herman Toothrot
  • 1,463
  • 3
  • 23
  • 53
  • Maybe try `mosh` https://mosh.org – Mark Setchell Nov 30 '20 at 08:58
  • @MarkSetchell I have mentioned mosh to the system administrator but it's not available on our server. – Herman Toothrot Nov 30 '20 at 09:16
  • try [tag:gnu-screen] – pynexj Nov 30 '20 at 09:50
  • @pynexj thank you but it doesn't work for my case since we have multiple nodes and every time I connect to the node with the lowest load, so it's random and screen/tmux would run only on a specific node so I can't get back to the same session. Also tmux/screen doesn't really have tabs, rather it divides the screen in sub-windows. – Herman Toothrot Dec 01 '20 at 08:03
  • how can you persist the working dir cross different nodes? – pynexj Dec 01 '20 at 08:05
  • @pynexj the file system is shared across nodes, I would just need to store somewhere the current directory and on reconnect to "cd {last used directory}". It doesn't seem that difficult but mobaxterm is not open source. – Herman Toothrot Dec 01 '20 at 09:46
  • ok. i think you can, for example, write a `cd()` function which override the builtin `cd` and save PWD in a file and in your `.bashrc` just read that file and `cd` into it. – pynexj Dec 01 '20 at 10:04
  • @pynexj that could be an idea, but how to deal with multiple tabs? – Herman Toothrot Dec 01 '20 at 11:22

0 Answers0