LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 11-26-2016, 02:04 PM   #1
Garrett85
Member
 
Registered: Jan 2011
Posts: 235

Rep: Reputation: 4
Editing PS1


Code:
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \w \$\[\033[00m\] '
PS1='\u@\h: \w \$
'

The above is from my ~/.bashrc file. But take a look at my prompt.

Code:
user@host ~/projects/learningCenter/udemy/learnAndUnderstandCPP/section6 $
Can anyone tell me why I'm getting the full path on my prompt when I am using a lowercase w instead of a uppercase W? I just want want the current working directory to show up, not the whole path.
 
Old 11-26-2016, 03:04 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Jessie 8.4
Posts: 5,873

Rep: Reputation: 348Reputation: 348Reputation: 348Reputation: 348
Change the lower case w to upper case W. The upper case W shows the basename of the current working directory.
See the Bash Prompt HOWTO for more information
http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/
 
1 members found this post helpful.
Old 11-26-2016, 03:06 PM   #3
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,252

Rep: Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559
wrong way round use
Code:
keithhedger@LFSHal: KKFileManager $PS1="\u@\h: \W \$"
keithhedger@LFSHal: KKFileManager $cd /media/LinuxData/Development64/Projects/KKFileManager
keithhedger@LFSHal: KKFileManager $
you beat me to it bigrigdriver
 
1 members found this post helpful.
Old 11-26-2016, 05:28 PM   #4
Garrett85
Member
 
Registered: Jan 2011
Posts: 235

Original Poster
Rep: Reputation: 4
I changed the .bashrc line to:

#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \w \$\[\033[00m\] '
PS1="\u@\h: \W \$"


And I'm still getting

user@host ~ $ cd projects/learningCenter/udemy/learnAndUnderstandCPP/section6/
user@host ~/projects/learningCenter/udemy/learnAndUnderstandCPP/section6 $
 
Old 11-26-2016, 05:34 PM   #5
Garrett85
Member
 
Registered: Jan 2011
Posts: 235

Original Poster
Rep: Reputation: 4
Update, the line PS1="\u@\h: \W \$" worked when I inputed it directly into the terminal but it's not having any affect from .bashrc. Also, even though it temporarily achieved my goal when I inputed it directly into the terminal it also caused the prompt to lose all of it's coloring. Also note that I did source .bashrc and completely exited and reopened as well.
 
Old 11-26-2016, 05:35 PM   #6
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,252

Rep: Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559Reputation: 559
PS1 may be getting changed what does
Code:
echo "$PS1"
give?
 
Old 11-26-2016, 05:45 PM   #7
Garrett85
Member
 
Registered: Jan 2011
Posts: 235

Original Poster
Rep: Reputation: 4
I got it. Instead of trying to insert my own line I just modified the existing line in the .bashrc file and replaced all the 'w's with 'W'. Thanks for your help.
 
  


Reply

Tags
bash, ps1


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] Customizing the PS1 kb2tfa Linux - Newbie 4 03-04-2016 06:29 AM
PS1 help. DEEP♂DARK♂FANTASY Linux - Software 5 08-01-2013 09:10 AM
[SOLVED] What's wrong with my PS1? 688a Slackware 1 10-25-2012 12:08 PM
Bash PS1 Fraeco Linux - Newbie 4 06-05-2011 05:24 AM
PS1 variable Kenny_Strawn Linux - General 4 12-15-2010 10:38 AM


All times are GMT -5. The time now is 02:09 AM.

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