The .bashrc file is a script that runs every time you open a Terminal window by pressing Ctrl+Alt+T or open a new tab in a Terminal window. This article will show you how to add a simple command to the .bashrc file that will check what you type into the cd command for transposed characters, missing characters, and too many characters.
You can add commands the .bashrc file that you want to run automatically every time you open a Terminal window. To add a spell check to the cd command we need to add a command to the .bashrc file. To edit the .bashrc file one must use gedit.
Type the following command at the prompt:
You can use any text editor such as vi and nano. Just replace “gedit” in the above command with the text editor you want to run.
Now scroll to the bottom of the .bashrc file and add the following line to the end of the file.
shopt -s cdspell
You can add a comment above the command so you remember what the command does. Simply put a number sign (#) at the beginning of the line, and then type in the description you want to add. After have added the command to the file, click “Save“.
Now close gedit (or other text editor) by clicking the “X” in the upper-left corner of the window. Now, if you make a small mistake (such as transposed characters) when typing the name of a directory in the cd command, the correct spelling displays on the next line and you are automatically taken to the directory that most closely matches what you typed.
Note: The setting you just added to the .bashrc file will not affect the current Terminal window session. You must close the Terminal window and log out and back in for the change to take affect.