Ask Your Question

New install of Fedora 28... terminal missing customization variables?

asked 2018-06-20 11:19:14 -0500

gde061 gravatar image

Hi -I would like someone to explain how things works in terms of initializing the (interactive) terminal session with variables like PS1 and PROMPT_COMMAND.

I installed basic Fedora 28 with Gnome, did a few modifications (dash to dock, add shortcut for <ctr>+<alt>+<t>, etc.) and I notice that unlike my other system, the terminal for my main user ID just says "Bash>" in plain white letters. The Title Bar just says "terminal".

When I started out, I the prompt was behaving similarly for "root" sessions in terms of color, but the title bar would switch to the more conventional <user>@<host>:<cwd>.

I started by looking at /etc/bashrc, which directed me to make a file in the /etc/profiles.d directory... which I did using a simple conditional script to set PS1 to one thing for UID not equal to 0, and another thing for UID is zero (root). Turns out things behaved kinda kooky, like if I want a red prompt after sudo su, I had to put that in /etc/profiles.d/ under the "user is NOT equal to root" section. Meanwhile the color for the current session user had to be set in ~/.bashrc

So (1) how does this work, and (2) where is the stuff that is changing the title bar when I sudo su?

I have things in a usable state presently, but still there is fancy color formatting for output of things like "ls" when I am elevated to root by sudo su that do not display when I am just plunking along in a non-elevated status. So how would I get those fancy color schemes for my regular users as well?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-06-20 14:13:21 -0500

florian gravatar image

updated 2018-06-20 16:11:14 -0500

One quick and dirty solution is to ignore what the author(s) of /etc/bashrc are recommending:

Just place your customized PS1 in /etc/bashrc, and if you like, place another customization as ~/.bashrc. Works just fine, including title bar (where in my case it shows PS1).

Example for /etc/bashrc:

if [ $(id -u) -eq 0 ];
PS1="\[\033[01;31m\]\u@\h:\[\033[00m\] \[\033[01;34m\]\w #\[\033[00m\] "
PS1="\[\033[01;32m\]\u@\h:\[\033[00m\] \[\033[01;34m\]\W $\[\033[00m\] "

Example for ~/.bashrc

PS1="\[\033[01;32m\]\u@\h:\[\033[00m\] \[\033[01;34m\]\w $\[\033[00m\] "
edit flag offensive delete link more

Question Tools

1 follower


Asked: 2018-06-20 11:19:14 -0500

Seen: 525 times

Last updated: Jun 20 '18