Courier
Courier

Reputation: 940

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?

Upvotes: 2

Views: 2245

Answers (1)

John Kugelman
John Kugelman

Reputation: 362037

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 "$@"
}

Upvotes: 11

Related Questions