Controlling the History and Setting the Shell Editor
Explore how to control your command-line history by setting variables to ignore spaces, duplicates, or specific commands. Learn to append history and limit its size for efficient tracking. Discover how to configure the shell editor by setting environment variables so programs like Git open your preferred text editor such as nano. This lesson guides you in customizing your shell environment for better productivity and privacy.
We'll cover the following...
Controlling the history
We can control which commands get stored in the history and how many entries are preserved in the current session and across all sessions, all through a handful of shell variables. Let’s add some to our .bashrc file.
The HISTCONTROL variable lets us ignore commands that start with a space. This can be really useful to hide commands containing sensitive information from our history. It’s often a default setting.
The HISTCONTROL variable also lets us ignore repeated duplicates. So, if we type ls three times in a row, we can have it saved only once. This only checks the previous command for duplicates, but it’s still a nice way to trim down the history a bit.
We can set one or both of these options like this:
HISTCONTROL=ignorespace:ignoredups
...