Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Currently it is:

michael@Castle2012-Ubuntu-laptop01:~/Dropnot/webs/rails_v3/linker/spec/controllers$

Outside of renaming my machine and directory structure...

How could I make it be something more like:

michael:controllers$
share|improve this question

3 Answers 3

up vote 34 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\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi

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\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u:\W\$ '
fi

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
1  
You can also have a lot of information... and then a carriage return at the end as in unix.stackexchange.com/q/88780/10043 –  Michael Durrant May 23 at 22:18

PROMPT_DIRTRIM=3

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
.../lib/apt/lists# 
share|improve this answer
1  
Just a sidenote: This requires Bash 4. –  Stefan Lasiewski Jun 18 at 0:12

This is my preferred display:

added in ~/.bashrc

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

display:

[user@hostname dirname]#
share|improve this answer

Your Answer

 
discard

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.