Prevent accidental terminal logouts in the bash shell
May 01, '03 09:25:00AM • Contributed by: kwyjibo
May 01, '03 09:25:00AM • Contributed by: kwyjibo
Typing Control-D on the command line has a different effect depending on the context. It is often used to send an EOF character to a particular command (when redirecting standard input to a file using cat, for example). Using emacs mode in the bash shell (the default mode), Control-D deletes one character forward. But if the command line is empty, it will log you out of the shell. To avoid this, add the following line to your .bash_profile:
shopt -s -o ignoreeofNow if you accidentally type Control-D on an empty command line, you will remain logged in and be presented with this friendly reminder:
Use "logout" to leave the shell.Control-D will still work as expected in other contexts.
•
[5,309 views]
