Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Currently it is:


Outside of renaming my machine and directory structure...

How could I make it be something more like:

share|improve this question

4 Answers 4

up vote 67 down vote accepted

To change it for the current terminal instance only

Just enter PS1='\u:\W\$ ' and press enter.

To change it "permanently"

In your ~/.bashrc, find the following section:

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

Remove the @\h, and replace the \w with an uppercase \W, so that it becomes:

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ '

Save, exit, close terminal and start another to see the result.

Tons more options!

  • See here for a more extensive howto, with many more options
  • See this answer for using up a tiny Python script to set the prompt so that the shortening only occurs when you are deep in a directory structure.
share|improve this answer
You can also have a lot of information... and then a carriage return at the end as in – Michael Durrant May 23 '14 at 22:18
Is there a way to make this global? In other words, if I sudo to another user, have this setting carry over, but only for myself (i.e., not for the user when they normally use their account)? – ctote May 14 at 16:20
In order to have a shared .bashrc that works on both Linux and OSX I've since switched to – Michael Durrant May 19 at 12:40
i.e. HOST='\033[02;36m\]\h' HOST=' '$HOST parse_git_branch () { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'; } TIME='\033[01;31m\]\t \033[01;32m\]' LOCATION=' \033[01;34m\]pwd | sed "s#(/[^/]\{1,\}/[^/]\{1,\}/[^/]\{1,\}/).*(/[^/]\{1,\}/[^/]\{1,\})/\{0,1\}#\1‌​_\2#g"' BRANCH=' \033[00;33m\]$(parse_git_branch)\[\033[00m\]\n\$ ' PS1=$TIME$USER$HOST$LOCATION$BRANCH PS2='\[\033[01;36m\]>' – Michael Durrant May 19 at 12:44
but see the answer for actual code to use. – Michael Durrant May 19 at 12:44


Will show only last 3 directory name in bash prompt. You can choose 1 to show only current directory.

The effect:

/var/lib/apt/lists# PROMPT_DIRTRIM=3
share|improve this answer
Just a sidenote: This requires Bash 4. – Stefan Lasiewski Jun 18 '14 at 0:12

This is my preferred prompt setting:

added in ~/.bashrc

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

it looks like this:

[user@hostname dirname]$

(with a space after the $ sign)

share|improve this answer

I realize this is super old but since nobody suggested creating an alias I figured I'd post. Using Bash Prompt Escape Sequences I made an alias shorten

In ~/.bash_aliases here you will notice the $Blue var to set the prompt colour which you can omit or change based on preference I also clear the terminal when calling shorten.

alias c='clear'

alias shorten='PS1="$Blue$USER:\W$ "&& c'

To achieve the OP's desired prompt string:

alias shorten='PS1="$USER:\W$ "'

I have colours defined in ~/.bashrccopy and pasted from On a side note what's with ansi code colours? I'm confused just looking at it.

Blue='\e[0;34m'         # Blue
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.