Edit Your Terminal Prompt to Show More Info

Nuwan Zen
Apr 4, 2021

--

Would you like to change your linux terminal prompt as above to show extra information such as

user[currentFolder]gitbranch

if so try this guide

edit ~/.bashrc

...
if [ "$color_prompt" = yes ]; then

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else...

You can find above line in the file and edit as below

...
if [ "$color_prompt" = yes ]; then

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[30;43m\][\W]\[\e[97;44m\]$(git symbolic-ref --short HEAD 2>/dev/null)\[\033[00m\] $ '
else
...

--

--

Nuwan Zen

Sometimes A software Engineer, sometimes a support engineer, sometimes a devops engineer, sometimes a cloud engineer :D That’s how the this life goes!