Editing the Bash Prompt

Let's say you're on the lab machine called mint. This is your default bash prompt:

mint[~]$ 

This is what you might see in a regular session:

mint[~]$ ls
Desktop/    Downloads/  public_html/    Documents/  class/
public/    unix_commands

To edit the bash prompt, fire up your favorite text editor on the .bashrc file that lives in your home directory:

vim ~/.bashrc

In the file, look for the variable called PS1 where your bash prompt string is stored. It'll probably have a value like this:

PS1='\h[\W]\$ '

You can add text to your prompt or special characters called escape sequences. For example, \h displays the hostname (mint) and \W displays the basename of your current directory. This Bash Prompt HOWTO is a handy reference for escape sequences.

After editing, save the file, pop up a new terminal, and marvel at your new bash prompt!


Back to SwatCS Help Docs