More than once I've accidentally run a number of commands and polluted my bash history. How do I close my terminal without saving my bash history? I'm using Fedora.
|
Your shell's history is saved in the file indicated by the
This also applies to zsh, but not to ksh which keeps saving to the file indicated by |
|||||
|
|
Short answer: Type this at the prompt:
This will kill your shell right away without the shell being able to do anything such as trap the signal, save history, execute Long answer: Note: These options are not mutually exclusive; they can be all used at once. Option 1: If you're a perfectionist when it comes to cluttering up your history file, then what you can do is modify the Option 2: If you want to control on a command-by-command basis what commands get left out of your history, you can set Option 3: If you just want to make it so when you close the terminal the shell exits immediately, you can
|
|||||||||||||||
|
|
There are two environment variables that bash uses to determine the history file and how many lines to write to it when the shell exits. You can throw away your session's history with either of these (set during the session you want to omit from your history file):
or
Either of these work fine in Bash on Fedora |
||||
|
|
|
I'm surprised to see no one has suggested |
|||||
|
|
Not sure why you care about your command history so much. If you need certain commands often, you might have more fun if you define aliases for them so you can get them back with two keystrokes rather than having to look for them in the history. |
|||
|
|
|
|||||||||
|
