How to have full directory path always shown in mac terminal?
Solution 1:
As I just removed oh my zsh
I had to change terminal settings a little:
Terminal -> Preferences -> Startup tab
, and change "Shell Opens With:" from "Default login shell" to Command and value /bin/bash
.
Now string export PS1='\u@\H:\w$'
works correct.
Solution 2:
With macOS Catalina, the default shell is zsh. You can either switch to the /bin/bash shell as explained in Maxim's answer. Or stay with the zsh shell and change the startup run command to say
PROMPT='%/ %# '
The %/ is for full path and %# is to indicate whether the shell is running with privileges. More explanation and the full list of customizations is here.
I found this info here.
You can add the startup run command mentioned above in the 'Run command: ' field at Terminal > Preferences > Profiles > Shell > Startup. This is what I did. You could instead add the command to the .zshrc file as well. Either way, quit and restart the terminal for the changes to take effect.