LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-03-2012, 09:04 AM   #1
mrpc_cambodia
Member
 
Registered: Jun 2004
Posts: 131

Rep: Reputation: 15
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
 
Old 01-03-2012, 09:12 AM   #2
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,812
Blog Entries: 1

Rep: Reputation: 259Reputation: 259Reputation: 259
Everything you ever wanted to know about bash prompts --> http://tldp.org/HOWTO/Bash-Prompt-HOWTO/
 
Old 01-03-2012, 11:57 AM   #3
shreyas08
LQ Newbie
 
Registered: Dec 2011
Posts: 12

Rep: Reputation: Disabled
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.
 
Old 01-03-2012, 02:08 PM   #4
kindofabuzz
Member
 
Registered: Mar 2010
Location: There
Distribution: Linux Mint 17.1
Posts: 237

Rep: Reputation: 45
http://www.cyberciti.biz/tips/howto-...up-prompt.html
 
Old 01-03-2012, 10:55 PM   #5
mrpc_cambodia
Member
 
Registered: Jun 2004
Posts: 131

Original Poster
Rep: Reputation: 15
here is my $PS1 output:

\h:\W \u\$
 
Old 01-04-2012, 09:09 AM   #6
weibullguy
ReliaFree Maintainer
 
Registered: Aug 2004
Location: Kalamazoo, Michigan
Distribution: Slackware-current, Cross Linux from Scratch, Gentoo
Posts: 2,812
Blog Entries: 1

Rep: Reputation: 259Reputation: 259Reputation: 259
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.
 
Old 01-05-2012, 06:38 AM   #7
shreyas08
LQ Newbie
 
Registered: Dec 2011
Posts: 12

Rep: Reputation: Disabled
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??
 
Old 01-05-2012, 08:46 AM   #8
makyo
Member
 
Registered: Aug 2006
Location: Saint Paul, MN, USA
Distribution: {Free,Open}BSD, CentOS, Debian, Fedora, Solaris, SuSE
Posts: 729

Rep: Reputation: 75
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Command path is in PATH but bash does not find the command. stf92 Linux - Newbie 17 03-23-2012 04:19 AM
[SOLVED] How to get the absolute path of the running executable file and current work path ? 915086731 Programming 3 11-01-2011 09:28 AM
How to shorten current path name cianoz Linux - Newbie 14 03-14-2011 07:50 AM
Basic - PICAXE, multiple commands as one command? Need to shorten code. jollyjoice Programming 3 03-13-2005 04:26 AM
Placing current path in the prompt zepplin611 Linux - General 2 05-13-2004 12:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration