简体   繁体   中英

How to disable cd command-line?

Typing 'cd' alone in unix terminal leads to Home directory. 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. I loose a lot of time by doing so.

To go Home directory, one would instead just need to type cd ~.

Any idea please?

You can use cd - to quickly return to the previous directory ( $OLDPWD ). In general, I recommend getting used to UNIX as it is. But if you really want to, add this function to ~/.bashrc . It will make cd with no arguments a noop.

cd() {
    (( $# > 0)) && builtin cd "$@"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM