I am having trouble reading this ps1 setting. when I echo $PS1 is see:
\[\e]0;\u@\h \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] \[\033[01;34m\]\w \$\[\033[00m\]
I know the e indicates a color setting for user at home, but i'm not sure what that debian stuff is about ( maybe referencing debian default settings?) I know the m is supposed to indicate the end of a color setting. but I have a difficult time reading this.
Could someone break this up for me, so each different item being set is on a separate line? Is it just each thing between a [xxx] counts as one item? I don't understand how come there isn't an equal number of opposite brackets. shouldn't there be something like a [[ or ]] for some of those?
I probably need to comment the hell out of the file until I can read the command line better
I'm hoping to try rearranging things like the date and its order, the current time, and things like the current working directory until i find a nice fit. Im hoping that by breaking them up line by line I can simply remove elements and add them without breaking something else. so it reads something akin to:
#Color of promt
xxxxx
#current working directory
xxxxx
#next thing I want to try out
xxxxx
any help would be greatly appreciated.
Help reading this PS1 prompt setting
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Topics in this forum are automatically closed 6 months after creation.
-
- Level 2
- Posts: 72
- Joined: Thu Mar 05, 2015 6:24 pm
Help reading this PS1 prompt setting
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
- catweazel
- Level 19
- Posts: 9763
- Joined: Fri Oct 12, 2012 9:44 pm
- Location: Australian Antarctic Territory
Re: Help reading this PS1 prompt setting
"There is, ultimately, only one truth -- cogito, ergo sum -- everything else is an assumption." - Me, my swansong.
Re: Help reading this PS1 prompt setting
The main documentation regarding PS1 is in the bash manpage. section PROMPTING:
That is, the bash manpage should be your first stop for stuff like this. It's long and unwieldy, hence the (Mint 18-specific) line numbers above, but a good source of information. Also note by the way that changing PS1 you'd do in ~/.bashrc.
[EDIT] Didn't earlier follow catweazel's link but that's actually surprisingly complete. "Bash manpage is the main source" is still useful I guess but otherwise the link seems nice enough.
man bash
, 1732g
. The ${debian_chroot:+($debian_chroot)}
is a bash parameter expansion: man bash
, 918g
, and means "if the environment variable $debian_chroot is not null or unset, run it as a command and insert its output here": also see "command substitution" just below the parameter expansion bit.That is, the bash manpage should be your first stop for stuff like this. It's long and unwieldy, hence the (Mint 18-specific) line numbers above, but a good source of information. Also note by the way that changing PS1 you'd do in ~/.bashrc.
[EDIT] Didn't earlier follow catweazel's link but that's actually surprisingly complete. "Bash manpage is the main source" is still useful I guess but otherwise the link seems nice enough.
Re: Help reading this PS1 prompt setting
Sure.
This just sets the terminal window title text.
Because of the tricky nature of the PS1 prompt, escape sequences need to be protected by escaped brackets,
This part sets the title bar text of the terminal window, where 'TITLE' would be whatever you want. The prompt has opted for the usual 'USER@HOST CWD', where CWD is the current working directory. The
Since this is being set with each PS1 instance, the title bar will always be updated. It's just a nice touch in a traditional setup. Sadly lost on me, as I don't use title bars, but it's still cool to keep in mind.
Not sure, as I never really saw it in action. I can't stand the default prompt, so I always change it. As a guess, I'd say it tells you if you're chrooted in (don't worry if that makes no sense) or not. What I can tell you, is that it's bash parameter expansion, setting (but not actually assigning) a default value, if it's not already set or empty.
Sets the foreground color to green. Unusual that it uses
The
Sets the foreground and background color to the default, which is typically white on black. This is utterly pointless, as far as I can see, since it changes the color again anyway. lol Who wrote this?!
Changes the color to grey, then
\[\e]0;\u@\h \w\a\]
This just sets the terminal window title text.
Because of the tricky nature of the PS1 prompt, escape sequences need to be protected by escaped brackets,
\[\]
; this is just for the PS1 prompt; possibly other PS* prompts too.\e]0;TITLE\a
This part sets the title bar text of the terminal window, where 'TITLE' would be whatever you want. The prompt has opted for the usual 'USER@HOST CWD', where CWD is the current working directory. The
\e];
sets it up to change the title to whatever you want, and \a
simply closes it, saying you've finished setting the title text.Since this is being set with each PS1 instance, the title bar will always be updated. It's just a nice touch in a traditional setup. Sadly lost on me, as I don't use title bars, but it's still cool to keep in mind.
${debian_chroot:+($debian_chroot)}
Not sure, as I never really saw it in action. I can't stand the default prompt, so I always change it. As a guess, I'd say it tells you if you're chrooted in (don't worry if that makes no sense) or not. What I can tell you, is that it's bash parameter expansion, setting (but not actually assigning) a default value, if it's not already set or empty.
\[\033[01;32m\]
Sets the foreground color to green. Unusual that it uses
\033
(sequence for the escape key) yet uses \e
(same thing) for the title change. Seems like an oversight which has stuck around for a long time. There's also no need for the leading 0 in the 01 part. Oh well.\u@\h
The
\u
is for the current user ($USER
), @
is just to say where the user is, and \h
is for the current host ($HOSTNAME
).\[\033[00m\]
Sets the foreground and background color to the default, which is typically white on black. This is utterly pointless, as far as I can see, since it changes the color again anyway. lol Who wrote this?!
\[\033[01;34m\]\w \$\[\033[00m\]
Changes the color to grey, then
\w
is for the current directory. The \$
is just for displaying the traditional prompt leader, like the >>>
in an interactive Python shell, if you're familiar with that, or the :
in less
or vim's command mode. If you're running as a non-root user, it'll show as $
, otherwise it'll show as #
. The last part just sets the color back to normal again.I'm also Terminalforlife on GitHub.
-
- Level 2
- Posts: 72
- Joined: Thu Mar 05, 2015 6:24 pm
Re: Help reading this PS1 prompt setting
thank you so much. very helpful replies.