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 am using bash, and in my .basrhrc: I have the following which defined how my prompt looks:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\w\[\033[00m\]:\[\033[01;34m\]\!:\#\[\033[00m\]\$ '

I think the \w display the current path of the shell.

Is there any way to limit the number of character used to display the current path of the shell?

share|improve this question
    
possible duplicate: superuser.com/questions/60555/… – quack quixote Mar 30 '10 at 3:14
up vote 2 down vote accepted

You can use \W (capital "W") which will make your home directory (/home/username) display as a tilde ('~') and only show the basename of the current directory. So an example might look like:

dir:509:9$ pwd
/home/username/dir
dir:510:10$ cd ..
~:511:11$ 

If you're using Bash 4, you can set the PROMPT_DIRTRIM shell variable to a number of trailing directory levels to display. But there was a bug in it which was fixed in a maintenance release (4.1, I think).

share|improve this answer

You must log in to answer this question.

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