LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Editing PS1 (https://www.linuxquestions.org/questions/linux-newbie-8/editing-ps1-4175594277/)

Garrett85 11-26-2016 01:04 PM

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.

bigrigdriver 11-26-2016 02:04 PM

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/

Keith Hedger 11-26-2016 02:06 PM

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

Garrett85 11-26-2016 04:28 PM

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 $

Garrett85 11-26-2016 04:34 PM

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.

Keith Hedger 11-26-2016 04:35 PM

PS1 may be getting changed what does
Code:

echo "$PS1"
give?

Garrett85 11-26-2016 04:45 PM

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.


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