> I do see this in .bashrc on Debian and there is nothing of it in .bashrc
> on Fedora. There is in fact a lot of stuff in .bashrc on Debian that is
> not there on Fedora.

I use a custom color prompt for my bash shell.  I had to use different 
methods in my Fedora and Debian qubes to get the prompt I wanted.  It's a 
little tricky because you have to check and see how the system files setup 
the $PS1 file.  Because I wanted the same definition in each of my qubes I 
ended up creating a /etc/profile.d/custom.sh file to define the prompt in 
Fedora templates to set the prompt in each appVM based on that template.  
The code  based on some adapted Debian or Ubuntu code.  There is also a 
bunch of code to setup definitions for colors and other terminal escape 
sequences.

My custom.sh produces prompt like:

[user@docker-fed-37:2 Fri 2023-05-05 17:35 GMT /etc/profile.d]$

where
user@docker-fed-37 is green
/etc/profile.d is bright_blue
the :2 represents the terminal number where numbering starts with :0


===custom.sh===

# User specific aliases and functions

term-control-colors () {
# https://mywiki.wooledge.org/BashFAQ/037
# Variables for terminal requests.
[[ -t 2 ]] && {
    alt=$(      tput smcup  || tput ti      ) # Start alt display
    ealt=$(     tput rmcup  || tput te      ) # End   alt display
    hide=$(     tput civis  || tput vi      ) # Hide cursor
    show=$(     tput cnorm  || tput ve      ) # Show cursor
    save=$(     tput sc                     ) # Save cursor
    load=$(     tput rc                     ) # Load cursor
    bold=$(     tput bold   || tput md      ) # Start bold
    stout=$(    tput smso   || tput so      ) # Start stand-out
    estout=$(   tput rmso   || tput se      ) # End stand-out
    under=$(    tput smul   || tput us      ) # Start underline
    eunder=$(   tput rmul   || tput ue      ) # End   underline
    reset=$(    tput sgr0   || tput me      ) # Reset cursor
    blink=$(    tput blink  || tput mb      ) # Start blinking
    italic=$(   tput sitm   || tput ZH      ) # Start italic
    eitalic=$(  tput ritm   || tput ZR      ) # End   italic
[[ $TERM != *-m ]] && {
    red=$(      tput setaf 1|| tput AF 1    )
    green=$(    tput setaf 2|| tput AF 2    )
    yellow=$(   tput setaf 3|| tput AF 3    )
    blue=$(     tput setaf 4|| tput AF 4    )
    bright_blue=$(     tput setaf 12|| tput AF 12    )
    magenta=$(  tput setaf 5|| tput AF 5    )
    cyan=$(     tput setaf 6|| tput AF 6    )
# for broken termcap databases with 16 ANSI colors
# blue=$'\e[0;34m'
# green=$'\e[0;32m'
# white=$'\e[0;37m'

}
    white=$(    tput setaf 7|| tput AF 7    )
    default=$(  tput op                     )
    eed=$(      tput ed     || tput cd      )   # Erase to end of display
    eel=$(      tput el     || tput ce      )   # Erase to end of line
    ebl=$(      tput el1    || tput cb      )   # Erase to beginning of line
    ewl=$eel$ebl                                # Erase whole line
    draw=$(     tput -S <<< '   enacs
                                smacs
                                acsc
                                rmacs' || { \
                tput eA; tput as;
                tput ac; tput ae;         } )   # Drawing characters
    back=$'\b'
} 2>/dev/null ||:
}

# set local definitions
term-control-colors

# my_blue=$'\e[0;34m'
# my_green=$'\e[0;32m'
# my_white=$'\e[0;37m'
# my_reset=$'\e[00m'

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
    else
color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='[\[$green\]\u@\h\[$reset\]:\l \D{%a %F %R %Z} 
\[$bright_blue\]\w\[$reset\]]\$ '
    # PS1='[\[\033[01;32m\]\u@\h\[\033[00m\]:\l \D{%a %F %R %Z} 
\[\033[01;34m\]\w\[\033[00m\]]\$ '
else
    PS1='[\u@\h:\l \D{%a %F %R %Z} \w]\$ '
fi
unset color_prompt force_color_prompt

===custom.sh===


Another alternative I explored is the setup the above or similar file in 
the appVM .bashrc.d file.

Unfortunately, the Debian default overrides any $PS1 string defined 
/etc/profile.d/custom.sh so I define and export a $CUSTOM_PS1 environment 
variable and then use it appropriately in my Debian .bashrc to set the $PS1 
string.  Also note that the term-control-colors function doesn't work in 
Debian login shell and the "my_" variable definitions can be used instead.


 

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/ebf3f6f7-cc4b-432a-9226-b3c7fb87e666n%40googlegroups.com.

Reply via email to