so my terminal prompt in vs code mac is showing the process ID and then $. my current shell is bash. but i want my prompt to say the literal name of the directory that i am in and then a $ sign. if you guys can also tell how to set blue color for directory and gold color for $ sign then it would be great! thank you
i tried using nano and PS1 things but i think i’m doing it the wrong way. i want something like say i have a directory called hello i want my terminal to say hello/ $
Ahmad zaeem Zahid is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
To change the terminal prompt you should edit the PS1
variable.
Make sure you are using BASH in your VSCode terminal (with echo $0
) and don’t already have the variable PROMPT_COMMAND
(with unset PROMPT_COMMAND
).
w the value of the PWD shell variable ($PWD), with $HOME
abbreviated with a tilde (uses the value of the
PROMPT_DIRTRIM variable)
W the basename of $PWD, with $HOME abbreviated with a tilde
$ if the effective UID is 0, a #, otherwise a $
As you can see in BASH manual (section “PROMPTING”), if you want your command prompt to only show the current directory (not full path), you have 2 choices:
PS1='w $'; PROMPT_DIRTRIM=1
: this will display.../dir $
if your current directory is/etc/path/to/this/dir
.PS1='W $'
: this will displaydir $
Try these in your terminal, and once you’re happy with the result store the PS1
variable definition (and PROMPT_DIRTRIM
if wanted) in your ~/.bashrc
file.