You are not logged in.

#1 2018-05-02 16:34:49

smerdjakov
Member
Registered: 2018-04-27
Posts: 11

"Profiles" of bash colour configuration for user and root? [SOLVED]

I managed to put together some code for better aesthetics of my terminal prompt. For a user ($), it's:

PS1='\[\e[1;31m\]\u@\h\[\e[m\]:\[\e[1;34m\]\W\[\e[m\]$ '

and for root (#), it's:

PS1='\[\e[1;31m\]\u@\h\[\e[m\]:\[\e[1;34m\]\W\[\e[m\]# '

So, I managed to make it persistent by putting the ($) one in ~/.bashrc, which now looks like this:

#
# ~/.bashrc
#

# If not running interactively, don't do anything
[[ $- != *i* ]] && return

alias ls='ls --color=auto'
#PS1='[\u@\h \W]\$ '
PS1='\[\e[1;31m\]\u@\h\[\e[m\]:\[\e[1;34m\]\W\[\e[m\]$ '

However, I'm still missing one piece of the puzzle. I want to force .bashrc to make different configuration "profiles" for root and for user. When I log in as root (mostly by su), I want my prompt to display '#' at the end, and when I do it as a user, I want a '$' at the end. I tried with if ... else ... fi, but it didn't work. Please, help.

Last edited by smerdjakov (2018-05-02 17:09:10)

Offline

#2 2018-05-02 16:55:08

progandy
Member
Registered: 2012-05-17
Posts: 5,322

Re: "Profiles" of bash colour configuration for user and root? [SOLVED]

For bash, this configuration belongs into .bashrc. You need one for your user and another for root.
https://wiki.archlinux.org/index.php/Ba … tion_files

Last edited by progandy (2018-05-02 16:56:29)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#3 2018-05-02 17:08:30

smerdjakov
Member
Registered: 2018-04-27
Posts: 11

Re: "Profiles" of bash colour configuration for user and root? [SOLVED]

Ah, I made another .bashrc and put it into /root directory. Now everything is as I want it to be. Thanks! smile

Offline

Board footer

Powered by FluxBB