Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to remove the long listing of the current directory in the shell prompt.

Its sometimes annoying when you are using a small shell window and it occupies the whole space in the window

I would rather prefer the just the current directory at the prompt.

root@Kiran:~/Downloads/Director1/Director2/Director3/Director4# I would prefer something like : root@Kiran:..Directory4#

or Better even,



share|improve this question

migrated from Nov 18 '11 at 12:24

This question came from our site for professional and enthusiast programmers.

The answers below can be found by executing man bash. – keith.layne Nov 18 '11 at 1:28

Try this:

export PS1='\u:\W\$ '
share|improve this answer
Although, I like seeing the whole working directory, so I just put a \n# at the end of my PS1 line and that moves the cursor down a line. – Rob Nov 18 '11 at 15:18
What does that Regular Expression do? @Rob: If you are the one that posted this answer and want to get your accounts merged, flag your post for moderator attention and type in the box that you would like to have your accounts migrated. In any case, welcome to Super User! :) – Tom Wijsman Nov 19 '11 at 19:35
No, that's not me. the \n just puts in a newline mark. I should've said PS1='\u:\w\n\$ ' That would make the prompt "user:fulldirectory{newline}$ " – Rob Nov 19 '11 at 21:35

You want to use \W and not \w when you export/set your PS1 variable:

export PS1='\u:\h \W #'
share|improve this answer

With Bash version 4+ you can set


in your .bashrc. The prompt for a non-root user:


and for root

host:.../dir #
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .