Wednesday, May 15, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 9645  / 1 Year ago, mon, february 6, 2023, 9:55:08

I have changed PS1 variable in /etc/bash.bashrc to



PS1="
[033[0;37m]342224214342224200$(if [[ $? == 0 ]]; then echo "[[033[0;32m][033[01;32m]342234223[033[0;37m]]342224200"; else echo "[[033[0;32m][033[01;31m]342234227[033[0;37m]]342224200"; fi)[$(if [[ ${EUID} == 0 ]]; then echo '[033[0;31m]h'; else echo '[033[0;33m]u[033[0;37m]@[033[0;96m]h'; fi)[033[0;37m]]342224200[[033[0;32m]w[033[0;37m]]
[033[0;37m]342224224342224200342224200342225274 [033[0m]"


Which works fine with all the commands. But when I run sudo -i command, PS1 value goes to the default. To get back the color scheme, I have to run PS1=<same value> manually. Any idea what might be causing this behaviour?


More From » command-line

 Answers
7

Add the PS1 line to /root/.bashrc.



The reason why the color goes back to default is because when you do sudo -i, it "simulates" a root login, and in turn sources (applies) root's .bashrc, which brings the color back to the default. So adding the PS1 line to root's .bashrc should do the trick.


[#29577] Monday, February 6, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
pilun

Total Points: 270
Total Questions: 100
Total Answers: 94

Location: England
Member since Sat, Feb 13, 2021
3 Years ago
pilun questions
Thu, Sep 16, 21, 18:43, 3 Years ago
Mon, Aug 23, 21, 04:32, 3 Years ago
Wed, Sep 14, 22, 11:04, 2 Years ago
;