bash PS1 debian setting - syntax
I noticed that on my Debian system the default PS1 value for non root users is, as reported by "echo $PS1":
Code:
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ More precisely, I found many documents and examples about PS1 customization, but the above syntax (particularly the ${debian_chroot:+($debian_chroot)} part) is either not used or used but not explained, as it's knowledge was taken for granted. Can someone explain it to me or tell me where to find some clear explanation? |
First let's see the syntax:
Code:
${debian_chroot:+($debian_chroot)} Regarding $debian_chroot it should be an alias for the chroot location, as set in /etc/debian_chroot. Not sure about this. Maybe a Debian expert might shed some light. |
Thanks a lot, I finally understood.
That kind of substitution is NOT explained in the bash man pages, is it? What about the first part of the value? Code:
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ Finally, as it's not every day to find a... guru :], a last question: how can I, while in man pages (less), search for a word located at the beginning of a line? |
Quote:
Quote:
Quote:
Code:
/^WORD_TO_SEARCH Code:
/^ *WORD_TO_SEARCH |
Thanks for your help and courtesy.
I made some more tests. The situation seems to be as follows. If I issue the "echo $PS1" command as "armando" user in a virtual terminal (tty) I get the expected output Code:
echo $PS1 Code:
echo $PS1 |
Sorry for late... I missed your last post! :redface:
Indeed it looks weird. The first part does not make sense to me: Code:
\[\e]0; /etc/profile is the first configuration file sourced at login, where PS1 is set for interactive shells as Code:
PS1='\u@\h:\w\$ ' Code:
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' Code:
PS1='\[\e]0;\u@\h: \w\a\]'$PS1 |
An update: looking at the Bash Prompt HOWTO, here, it looks like the escape sequence at the beginning is meant to set the terminal title. This is the reason why only pseudo-terminal allocations bring to that apparently weird prompt (actually it was my ignorance).
In the ANSI escape sequences the symbol \[ begins a sequence of non-printing characters. The symbol \] terminates it. So the part in grey: Code:
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ Code:
\[\e]0;\w@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ Code:
\e]0; |
Sorry for digging up an older thread but, I believe that this portion of the PS1 value:
Code:
\[\e]0; \[ {begin non-print chars} \e]0; {"Window Title" color and boldness default} \u@\h: \w\a\] {Set term title as - $USER@$HOSTNAME: $PWD#} This is all kind of hazed speculation seeing as my days 'beautifying' my Xterm are long gone. Goodluck. |
Looky what I found...
Taken from an answer on the Stackexchange website titled: $PS1 on Ubuntu VM does not match actual prompt
This explains pretty much all of it, but I still don't understand the purpose of the bell character (/a). EDIT: Answered my own question. Information added. See following 2 posts for details. The default $PS1 in Ubuntu consists of three parts: |
Quote:
You almost certainly have this disabled -- to hear it run: Code:
modprobe pcspkr |
About that 'bell'...
Quote:
After experimenting with the PS1 variable myself, I determined that in this case the bell character (/a) separates the shell title from the shell prompt. Believe it or not I created an account specifically to post to this thread. Being a super-noob, everything I know has been researched myself... so I figured I'd share the love 'n' learnin' ;). Please excuse the excessive formatting, I only mean to make it easier for those that just want the 'meat' of the information. |
All times are GMT -5. The time now is 03:22 AM. |