2

How can I set -P flag to every cd command? I do that every time. There are LS flag environment variable which I could use for ls command so I wonder can -P be set as default?

  • Notice that this question is more suited for Stack Overflow, since the question is not Ubuntu specific and is about programming. (This question is off-topic.) – edwin Jul 15 '13 at 2:36
  • 1
    @edwin It's definitely not about programming. I'd say it's more suited to Super User or maybe Server Fault. – Steven K Jul 15 '13 at 2:42
  • OK, thanks for adding/correcting. – edwin Jul 15 '13 at 2:43
3

Open the file /home/your-username/.bashrc and add the following line to the end:

alias cd='cd -P'

Open a new terminal, and try using cd to see if it worked for you.

1

Try this,

set -o physical

From the set section in man bash,

-o option-name
The option-name can be one of the following:
...
physical
Same as -P.
...
-P If set, the shell does not follow symbolic links when executing commands such as cd that change the current working directory. It uses the physical directory structure instead. By default, bash follows the logical chain of directories when performing commands which change the current directory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.