[英]How to disable cd command-line?
Typing 'cd' alone in unix terminal leads to Home directory. 在unix终端中单独键入'cd'会导致主目录。 I wish to disable this functionality.
我希望禁用此功能。 Usually I make the error of typing enter just after cd, and then each time I need to comback to the previous working directory.
通常我在cd之后输入输入的错误,然后每次我需要comback到上一个工作目录。 I loose a lot of time by doing so.
这样做我浪费了很多时间。
To go Home directory, one would instead just need to type cd ~. 要转到主目录,只需要输入cd~即可。
Any idea please? 有什么好主意吗?
You can use cd -
to quickly return to the previous directory ( $OLDPWD
). 您可以使用
cd -
快速返回上一个目录( $OLDPWD
)。 In general, I recommend getting used to UNIX as it is. 一般来说,我建议习惯使用UNIX。 But if you really want to, add this function to
~/.bashrc
. 但如果你真的想要,请将此函数添加到
~/.bashrc
。 It will make cd
with no arguments a noop. 它会使没有参数的
cd
成为noop。
cd() {
(( $# > 0)) && builtin cd "$@"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.