Clean Code

Ubuntu - how to shorten bash prompt on ubuntu


We could be faced with very long bash prompt on ubuntu as the following example.


Then, we need to shorten the bash prompt. Let’s figure out how to do it.

For immediate effect but just once

On terminal, just type the following command and enter. It works promptly.

PS1=’\u:\W$$ ‘

The long bash prompt above becomes as below.


or you can apply the following command.

PS1=’$ ‘

It makes the long line as below


You may need to figure out where you are using the pwd bash command.

For permanent effect

You can add the following option in your .bash_profile or .bashrc file.

PS1=’\u:\W$$ ‘

Then, relaunch the terminal.


You can refer to here for further detailed information.

Similar Posts