Why should I quit? Why should I quit? Why can't I exit with exit? Why... yes, shell does exit with exit, but, however, what we're talking about is not that cheap...
In our daily work environment, there is such a characteristic. We will first log on to a central machine, and then log on to our target machine from here. Why? Because of the password and the annoying password. In this environment, a password is required only when you log on to the central machine. Then, no password is required. This is a very important thing. In particular, when dealing with a large number of machines and a large number of people, it is a pleasure not to remember those endless passwords.
This method also brings trouble, that is, how to exit elegantly from the nested shell after the work is finished?
Of course, you can ignore him and cut off the network directly so that those login shells can be hung there, but this is very simple and rude. Behave elegantly. So we have to go back and forth again and again. Return one set of machines, and then another set of machines ...... One day you will feel intolerable.
Many people have such a habit: At least it is written in the book-when you think you can't endure it, you will think of writing a script... The problem is, can this problem be solved through a script? At least I don't see any hope. I don't doubt the ability to write scripts, but I don't know where I can put the scripts? On which machine should the script be placed? Is it a central machine? Target machine? My own machine? Or every machine? You need to know that there are countless target machines in the hands of different employees... Maintenance is impossible.
Therefore, I chose to start with the shell mode of Emacs. On my own machine, I wrote such a function,
This function will automatically help me exit elegantly from the shell session. This command is bound to the C-c e key combination. When I need to exit a multi-layer nested shell session, just add a prefix, such as C-U 3 c-c E or a simpler C-3 c-c e, you can exit a layer-3 nested shell session at a time.