Working on the Linux command line: How to bash `cd` with autocorrect

Posted Over 2 years ago. Visible to the public. Repeats.

There is an option you can set so that when using the cd command, small typos are automatically corrected. Add the following to your ~/.bashrc:

# cd: autocorrect small typos and use best guess
shopt -s cdspell 

Example:

cd Porjects
# Projects

pwd
# /home/judith/Projects

Also, I recommend adding aliases for your most common typos of commands you regularly use to your ~/bashrc. Which ones that are is highly personal, for me it's e.g. tig:

alias tog='tig'
alias tug='tig'
Last edit
3 months ago
Michael Leimstädtner
License
Source code in this card is licensed under the MIT License.
Posted to makandra dev (2021-09-17 17:09)