How to customize terminal prompt?

Hello,
is it possible to alter .bashrc as to obtain a more customized terminal prompt?
In particular, I am looking to place the path and the actual commands on two separate lines such as in:

# original
/Home/Documents/MyFolder$ ls -l
# custom
/Home/Documents/MyFolder
$ ls -l

Thank you

1 Like
export PS1='\w\n$ '
export PS1='${PWD}\n$ '

bash: GNU Bourne-Again SHell | bash Commands | Man Pages | ManKier

6 Likes

Thank you. Is there also a way to change the color of the first part? (the \w and ${PWD} bit?

1 Like
BGREEN="\[\e[1;32m\]"
RESET="\[\e[m\]"
export PS1="${BGREEN}\${PWD}${RESET}\n$ "

bash - How to change the output color of echo in Linux - Stack Overflow

2 Likes

These days, thanks to: Changes/Color Bash Prompt - Fedora Project Wiki

It’s better just to set any of these on your .bashrc file:

PROMPT_COLOR      
PROMPT_COMMAND    
PROMPT_DIRECTORY  
PROMPT_SEPARATOR 
PROMPT_USERHOST

You can check the current value of any of those by simply:

echo $PROMPT_USERHOST

You can test them out (temporary change) by:

# chage the prompt color to yellow
PROMPT_COLOR=33

# chage the directory display from whole path to current
PROMPT_DIRECTORY="\W"

Note:
You can always export them if you prefer; in the terminal or in .bashrc.

This way, you can easily change the prompt while building on top of the change aforementioned.

1 Like