How to Stop Commands from Appearing in Bash History


1 min read

I usually don't want my secrets to show up in my bash history in the $HOME/.bash_history file. Long ago, folks told me that using a trailing space will solve this issue, but it didn't. Apparently, there's some extra stuff to do

Just do


The above also helps with getting rid of duplicate commands from the bash history, which is pretty cool ๐Ÿ†’๐Ÿ˜Ž๐Ÿ‘Œ since I use fzf to search through my history and choose commands, and when I search through a command with some strings, sometimes same result shows up multiple times - so many times that it's crazy and I just wish it just showed one unique result and get rid of duplicates, now this is possible because fzf looks at my $HOME/.bash_history only to look at all my past commands and if the bash history file contains unique commands, all is good, right? ;) By the way, I use fzf as part of my Ctrl + r keybinding for reverse search over all commands.

fzf has so many ideas for keybindings themselves - , apart from community's ideas ๐Ÿ’ก๐Ÿ˜„