LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   shorten command prompt current path (https://www.linuxquestions.org/questions/linux-newbie-8/shorten-command-prompt-current-path-921783/)

mrpc_cambodia 01-03-2012 09:04 AM

shorten command prompt current path
 
Hi,

using terminal console, when i change directory into a deep one, the command prompt path on the left shows the whole path, this way it almost fills the whole width of the screen. Can someone tell me a method to make it show only the last dir name so that there is more space for me to input command line.


Thanks,

mrpc_cambodia

weibullguy 01-03-2012 09:12 AM

Everything you ever wanted to know about bash prompts --> http://tldp.org/HOWTO/Bash-Prompt-HOWTO/

shreyas08 01-03-2012 11:57 AM

whatever you see as command prompt is because of the environment variable PS1.

Please paste the output of echo $PS1, so that i can help you out in better way.

kindofabuzz 01-03-2012 02:08 PM

http://www.cyberciti.biz/tips/howto-...up-prompt.html

mrpc_cambodia 01-03-2012 10:55 PM

here is my $PS1 output:

\h:\W \u\$

weibullguy 01-04-2012 09:09 AM

That will give you the hostname up to the first '.' (\h) followed by the basename of the current working directory (\W) and finally your user name (\u). That PS1 wouldn't cause the behavior you describe. Even if you were in the directory /some/really/really/really/deep/dark/directory/bin, the \W would cause only the bin to be shown in your prompt. Are you sure it is a capital W, not a lower case w? Either way, the link I originally gave you has the answer, but I'll give a more precise link http://tldp.org/HOWTO/Bash-Prompt-HO...sequences.html.

shreyas08 01-05-2012 06:38 AM

Try setting this as your PS1
[\u@\h \W]\$

This way if you are /really/really/deep/inside/bin you will see prompt as [root@hostname bin]#

I think that is what you what-- right??

makyo 01-05-2012 08:46 AM

Hi.

Another tutorial for comparison: http://www.ibm.com/developerworks/li...mpt/index.html

A utility that has themes, can have different prompts for different applications, etc.: http://bashish.sourceforge.net/index.html (no recent updates).

Best wishes ... cheers, makyo


All times are GMT -5. The time now is 08:25 PM.