linux: 更正别名的输入错误?

linux: correct typing errors with aliases?

当我在 shell 工作并且写得很快时,有时我会写“c d..”而不是 "cd .."。有什么办法(比如 bash-别名)用我奇怪的拼写来执行 "cd .." 吗? (我已经尝试在我的 .bashrc 中创建一个别名,但是 bash 然后说

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

因为它只能使用单字别名,不是吗?)

谢谢 4 你的快速帮助 :D

您可以将其添加到您的 .bashrc :D

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