Thursday, February 19, 2009

Command Spell Correction in Bash

If you tend to make mistakes while typing, bash can be a a little less than helpful; just spitting out a "No such file or directory." One small hack which helps towards this is the automatic spell correction built into bash. This will correct small typing errors made with the cd command as follows.

user@host:~ $ cd /ect
/etc
user@host:/etc$

It can be enabled for the current shell by

$ shopt -s cdspell

As before, you can make the effect more permanent by echoing the command into .bash_profile.

1 comment: