首页 > 其他 > 详细

关闭zsh的auto cd功能

时间:2016-02-04 00:17:07      阅读:265      评论:0      收藏:0      [点我收藏+]

前段时间切到了zsh环境,用着确实挺好,方便快捷什么的。
尤其是auto cd这个功能,太方便了,想进入某个目录直接敲目录名就好,完全不用先敲cd再敲目录名。

技术分享

就像这样,轻松进入文件夹,多棒!

现在问题就来了!
如果当前目录下有个文件夹的名字和我的某个命令名字相同会出现什么情况?
答案是不确定,时而自动进入文件夹,时而运行命令……
技术分享
这一次是进入cmake目录

技术分享
这一次又运行了cmake

坑爹呢?!

在终端输入man zshoptions可以查询到zsh所有的option的解释
里面有这么一条

AUTO_CD (-J)
          If a command is issued that can't be executed as a normal command, and the command is the name of a directory, perform the cd command to that directory. This option is only applicable  if the  option SHIN_STDIN  is set, i.e. if commands are being read from standard input. The option  is  designed for interactive use; it is recommended that cd be used explicitly in scripts to avoid ambiguity. 

唔,看起来很像是这货,虽然说是只有在这个命令无法工作的时候才会自动进入文件夹,但是完全没起作用……
这个功能太菜了,我们不要,关掉!

在终端中输入unsetopt AUTO_CD
再试下

技术分享
这就对喽!

关闭zsh的auto cd功能

原文:http://www.cnblogs.com/AkiPeroro/p/guan-bizsh-deauto-cd-gong-neng.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!