So I have searched for this but I didn't find anything which addresses this. I frequently connect to a remote server through ssh on which I don't have sudo permissions.
Let's say the connection gets terminated/reset by the remote server by inactivity or other reasons. Now all I want is that before the remote server terminates my connection it should run a pwd. I know there are ways to prolong/prevent remote server from terminating your connection, but I would like it to run a custom command of my choice before termination