[英]BASH blank alias to 'cd'
I am a happy BASH user. 我是一个快乐的BASH用户。 I do not want to switch to another shell (in this case ZSH). 我不想切换到另一个shell(在这种情况下是ZSH)。
ZSH has this ability to change a directory without necessarily typing: ZSH具有更改目录的能力,无需键入:
cd /to/a/directory
What would be the correct alias (or maybe BASH function) to change directories without having to type cd
? 在不必键入cd
情况下更改目录的正确别名(或BASH函数)是什么?
On my above example, moving to /to/a/directory would be done like this: 在上面的例子中,移动到/ to / a /目录将完成如下:
/to/a/directory
I have tried: 我试过了:
alias ''='cd '
alias ""='cd '
alias " "='cd '
Any ideas? 有任何想法吗?
It's an option added in version 4.0 of Bash . 这是Bash 4.0版中添加的一个选项。 You can set it with: 你可以用它来设置:
$ shopt -s autocd
Put that in your .bashrc
file to enable it always. 将它放在.bashrc
文件中以始终启用它。
I don't think you'll be able to have a "blank" alias, it doesn't really make sense.. 我认为你不会有一个“空白”的别名,它真的没有意义..
bash version 4.0 added the autocd
option, which is set by running shopt -s autocd
(as mipadi answered) bash 4.0版添加了autocd
选项,该选项通过运行shopt -s autocd
(如mipadi回答)
There is no such option in previous versions of bash, annoying. 在以前版本的bash中没有这样的选项,很烦人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.