[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bash default /etc/bash.bashrc overwrites PS1 even if SUDO_PS1 is set

From: Eric Engstrom
Subject: Bash default /etc/bash.bashrc overwrites PS1 even if SUDO_PS1 is set
Date: Mon, 18 Dec 2017 10:25:59 -0600
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.0.1

Dear Bash Maintainer(s),

Bash's default /etc/bash.bashrc (on debian systems at least) blindly
overwrites PS1 even if it's been set already.  This makes it difficult
to use sudo's abiltity to set PS1 via the SUDO_PS1 env var.

Perhaps overly simplistic, but the following modification seems to work
in all the situations I've tried:

    --- /etc/bash.bashrc.orig       2014-11-12 17:08:49.000000000 -0600
    +++ /etc/bash.bashrc    2015-06-24 12:13:36.445096411 -0500
    @@ -16,7 +16,10 @@

     # set a fancy prompt (non-color, overwrite the one in /etc/profile)
    -PS1='${debian_chroot:+($debian_chroot)address@hidden:\w\$ '
    +# but only if not SUDOing and have SUDO_PS1 set; then assume smart
    +if ! [ -n "${SUDO_USER}" -a -n "${SUDO_PS1}" ]; then
    +  PS1='${debian_chroot:+($debian_chroot)address@hidden:\w\$ '

     # Commented out, don't overwrite xterm -T "title" -n "icontitle" by
     # If this is an xterm set the title to address@hidden:dir

Eric Engstrom - address@hidden - PGP Key: 0xC440235DF11F74CF
$/='O'; eval ($_='print $_^pack"c25",<DATA>');

reply via email to

[Prev in Thread] Current Thread [Next in Thread]