Stop letting cd typos turn your shell into a spelling test

Environment & Shell Customization (Aliases/Functions/.Bashrc)

Stop letting cd typos turn your shell into a spelling test

🧩 The Challenge

You’re rushing to fix a dead service, type cd /var/log/nginx instead of /var/log/ngnix, and your shell hits you with a tedious no such file error that makes you want to throw your ThinkPad.

💡 The Fix

Turn on bash cdspell and your shell will silently fix minor typos on the fly without making you retype the whole path.

shopt -s cdspell

⚙️ Why It Works

Bash actually checks the directory name in your command, calculates the Levenshtein distance against nearby directory names, and automatically corrects single-character transposition or spelling errors before changing directories.

🚀 Pro-Tip: Drop that straight into your .bashrc and wonder why you spent years fixing your own typos manually.

Linux Tips & Tricks | © ngelinux.com | 12/3/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted