There are some settings that are very useful if you work on the terminal a lot. Many of the cool ones are not enabled by default – this is a small list of the configuration settings that I use to make my terminal usage more productive.
This is part 3 of the Customizing the Terminal series. Already published posts in this series are…
1. Case Correction
I like to title case my folders and files’ names. The folders in my home are ‘Scripts’, ‘Documents’, ‘Temp’ etc. The first character is in upper case. But when I work on the command line, I don’t always remember to uppercase the first character when trying to cd into a folder. Consequently, the tabbing will not work. Fortunately, there is an option that auto corrects the case for you. Just open a terminal and type in this command…
shopt -s nocaseglob
Other useful shopt option are…
- Corrects typos in your file/directory name.
- Makes sure that histories in multiple simultaneous shells don’t overwrite each other.
2. Select Which Commands to Store in History
By default, all commands you type in are stored in the history. You can pick and chose the commands you want to store by putting the option…
~/.bash_profile file. This will make sure that bash don’t store any command beginning with the space character. So if you want bash to forget that you typed in ‘ls’, just type in ‘ ls'(<space>ls).
3. Don’t Store Duplicate Commands in your History
As I said earlier, all commands you type are stored – even the duplicate ones. You can prevent this by putting this text in your
If you want to ignore spaced commands and want to prevent storing of duplicate commands, use the option…
4. Auto-complete Command from History
Picture this – you type in ‘ssh’ and press the ‘Page Up’ key – and bash automatically fetches the last command that starts with ssh – and completes the command for you. Well, its possible – add the following line in your ‘.bash_profile’ file…
Now, create a file called
.inputrc in your home and enter this into it…
#Page up/page down "\e[5~": history-search-backward "\e[6~": history-search-forward
Yes, I am aware of the up Ctrl+R trick – that comes in the next post.
5. Infinite History
You can increase or decrease the size of the history by adding this line in the
export HISTSIZE=500 export HISTFILESIZE=500
This will limit the commands to be stored in the history to 500. If you want to remove the limit use these lines…
unset HISTSIZE unset HISTFILESIZE
There is a good chance that this will make your history file quite huge – use with care.
Please share your configuration settings for bash in the comments.