Tw1x Tw1x - 1 year ago 100
Bash Question

linux: correct typing errors with aliases?

When I work in the shell and write fast it happens sometimes that I write " c d.." instead of "cd ..". Is there any way (like an bash-alias) to execute "cd .." with my weird spelling?
(I've already tried to create an alias in my .bashrc but bash then says

bash: alias: `c d..': invalid alias name

because it can only use single-word aliases, doesn't it?)

Thank you 4 your quick help :D

jDo jDo
Answer Source

You could add this to your .bashrc :D

function c() {
    if [ "$1" = d.. ] ; then
        builtin cd ..