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

When I start to enter in different folder the path is registered in my command line and I don't know how to remove it. I am almost sure my question wasn't clear. An example is always better. Once in home:

luiz@feynman:~$ cd Music/
luiz@feynman:~/Music$ cd Beatles/
luiz@feynman:~/Music/Beatles$ cd 17\ Love/

What is annoying me is this :~/Music or ~/Music/Beatles before $. It seems a stupid problem but when I need to enter into many folders is really a big problem. I guess I should change something in my .bashrc, but I don't know what.

Thanks

share|improve this question

migrated from stackoverflow.com Apr 8 '12 at 1:38

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

    
Off-topic. But Google for Bash PS1. – Oliver Charlesworth Apr 7 '12 at 15:38
    
Check my answer. – Shiplu Apr 7 '12 at 16:01
up vote 2 down vote accepted

look at and edit the value of $PS1. It contains the template for your prompt.

Something like '\u@\h \w $ ' is typical, in this the '\w' is a placeholder for the working directory. SettingPS1'\u@\h $ '` would remove the working directory.

For full details on how to set PS1, consult the bash man page

share|improve this answer
    
Thank you very much je4d – ziulfer Apr 7 '12 at 16:01
    
\W instead of \w will show only the directory you are in – Rob Apr 8 '12 at 2:38

You can use this prompt for PS1

PS1='\u@\h: $(x=$(pwd); l=${#x}; if [ $l -lt 24 ]; then echo $x; else echo ... ${x: -20};fi;)\$'

Just put this at the very end of your .bashrc. From now every time you go to a path with a length greater than 24 it'll show the last 20 characters preceding by .... In fact when we go deep down a directory only the last directories become significant. Because we already know where we started.

share|improve this answer
    
thanks shiplu.mokadd.im, I've already done what @je4d. But I will try your elegant suggestion latter. – ziulfer Apr 7 '12 at 16:04

Or you could use PROMPT_DIRTRIM to only include the last couple of directories in the prompt.

share|improve this answer

You must log in to answer this question.

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