gigiux
(Luigi Marongiu)
April 7, 2024, 6:01am
1
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
vgaetera
(Vladislav Grigoryev)
April 7, 2024, 6:20am
2
6 Likes
gigiux
(Luigi Marongiu)
April 10, 2024, 5:57am
3
Thank you. Is there also a way to change the color of the first part? (the \w
and ${PWD}
bit?
1 Like
vgaetera
(Vladislav Grigoryev)
April 10, 2024, 7:12am
4
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
renich
(Renich Bon Ćirić)
April 24, 2025, 1:15am
5
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