Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是一个快乐的 BASH 用户。我不想切换到另一个 shell(在本例中为 ZSH)。
ZSH 具有更改目录的能力,而无需键入:
cd /to/a/directory
无需键入即可更改目录的正确别名(或者可能是 BASH 函数)是cd什么?
cd
在我上面的示例中,移动到 /to/a/directory 将像这样完成:
/to/a/directory
我努力了:
alias ''='cd ' alias ""='cd ' alias " "='cd '
有任何想法吗?
这是 Bash 4.0 版中添加的一个选项。你可以设置它:
$ shopt -s autocd
将它放在您的.bashrc文件中以始终启用它。
.bashrc
我认为你不能有一个“空白”别名,这真的没有意义..
bash 4.0 版添加了autocd通过运行设置的选项shopt -s autocd(正如 mipadi 回答的那样)
autocd
shopt -s autocd
以前版本的 bash 中没有这样的选项,烦人。