LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 01:04 PM   #1
Garrett85
Member
 
Registered: Jan 2011
Posts: 328

Rep: Reputation: 6
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, 02:04 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian stable
Posts: 5,908

Rep: Reputation: 356Reputation: 356Reputation: 356Reputation: 356
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, 02:06 PM   #3
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 3,072

Rep: Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832Reputation: 832
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, 04:28 PM   #4
Garrett85
Member
 
Registered: Jan 2011
Posts: 328

Original Poster
Rep: Reputation: 6
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, 04:34 PM   #5
Garrett85
Member
 
Registered: Jan 2011
Posts: 328

Original Poster
Rep: Reputation: 6
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, 04:35 PM   #6
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 3,072

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

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

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

All times are GMT -5. The time now is 11:55 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
Open Source Consulting | Domain Registration