Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Colouring is gone on my terminal after a cfg-update.
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
LemonadeLlama
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2021
Posts: 101
Location: New Zealand

PostPosted: Tue Oct 05, 2021 9:06 am    Post subject: Colouring is gone on my terminal after a cfg-update. Reply with quote

I updated my system recently, and now, my terminal isn't displaying colours any more.

Tools like emerge will still show colours, but my hostname and machine name at the start of each line aren't coloured.

I'm using Alacritty if that helps.
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Tue Oct 05, 2021 9:08 am    Post subject: Reply with quote

Plz try
Code:

emerge -1av bash
dispatch-conf

_________________
:)
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Wed Oct 06, 2021 1:31 am    Post subject: Reply with quote

Is your prompt emitting color control sequences that the terminal ignores, or is the prompt not generating color codes at all?
Back to top
View user's profile Send private message
luna80
Veteran
Veteran


Joined: 01 Feb 2004
Posts: 1546
Location: switzerland

PostPosted: Wed Oct 06, 2021 3:30 am    Post subject: Reply with quote

maybe something with your ~.bashrc file?

root has the same problem or only your user?
_________________
*** !f j00 c4n r34D tH15 tH3N j00 n33D t0 l0g Off ***
Back to top
View user's profile Send private message
LemonadeLlama
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2021
Posts: 101
Location: New Zealand

PostPosted: Thu Oct 07, 2021 9:14 am    Post subject: Reply with quote

luna80 wrote:
maybe something with your ~.bashrc file?

root has the same problem or only your user?


This is what my .bashrc file looks like.

Code:
# /etc/skel/.bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
   # Shell is non-interactive.  Be done now!
   return
fi


# Put your fun stuff here.
alias ll="ls -al"
alias snooze="sudo loginctl suspend"
alias minecraft="MESA_GLSL_CACHE_DISABLE=true /usr/bin/minecraft-launcher"
alias update-all="sudo emerge --ask --verbose --newuse --deep --with-bdeps=y --update @world"


Also it's for everyone. I'm the only user on my PC, but when I type in
Code:
sudo su
to become root, the colours are still missing.

Also I'm not sure what you mean by "Is your prompt emitting color control sequences" :?:
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Thu Oct 07, 2021 2:41 pm    Post subject: Reply with quote

Code:

# /etc/bash/bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
   # Shell is non-interactive.  Be done now!
   return
fi

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.  #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

# Disable completion when the input buffer is empty.  i.e. Hitting tab
# and waiting a long time for bash to expand all of $PATH.
shopt -s no_empty_cmd_completion

# Enable history appending instead of overwriting when exiting.  #139609
shopt -s histappend

# Save each command to the history file as it's executed.  #517342
# This does mean sessions get interleaved when reading later on, but this
# way the history is always up to date.  History is not synced across live
# sessions though; that is what `history -n` does.
# Disabled by default due to concerns related to system recovery when $HOME
# is under duress, or lives somewhere flaky (like NFS).  Constantly syncing
# the history will halt the shell prompt until it's finished.
#PROMPT_COMMAND='history -a'

# Change the window title of X terminals
case ${TERM} in
   [aEkx]term*|rxvt*|gnome*|konsole*|interix)
      PS1='\[\033]0;\u@\h:\w\007\]'
      ;;
   screen*)
      PS1='\[\033k\u@\h:\w\033\\\]'
      ;;
   *)
      unset PS1
      ;;
esac

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.
# We run dircolors directly due to its changes in file syntax and
# terminal name patching.
use_color=false
if type -P dircolors >/dev/null ; then
   # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
   LS_COLORS=
   if [[ -f ~/.dir_colors ]] ; then
      eval "$(dircolors -b ~/.dir_colors)"
   elif [[ -f /etc/DIR_COLORS ]] ; then
      eval "$(dircolors -b /etc/DIR_COLORS)"
   else
      eval "$(dircolors -b)"
   fi
   # Note: We always evaluate the LS_COLORS setting even when it's the
   # default.  If it isn't set, then `ls` will only colorize by default
   # based on file attributes and ignore extensions (even the compiled
   # in defaults of dircolors). #583814
   if [[ -n ${LS_COLORS:+set} ]] ; then
      use_color=true
   else
      # Delete it if it's empty as it's useless in that case.
      unset LS_COLORS
   fi
else
   # Some systems (e.g. BSD & embedded) don't typically come with
   # dircolors so we need to hardcode some terminals in here.
   case ${TERM} in
   [aEkx]term*|rxvt*|gnome*|konsole*|screen|cons25|*color) use_color=true;;
   esac
fi

if ${use_color} ; then
   if [[ ${EUID} == 0 ]] ; then
      PS1+='\[\033[01;31m\]\h\[\033[01;34m\] \w \$\[\033[00m\] '
   else
      PS1+='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
   fi

   alias ls='ls --color=auto'
   alias grep='grep --colour=auto'
   alias egrep='egrep --colour=auto'
   alias fgrep='fgrep --colour=auto'
else
   # show root@ when we don't have colors
   PS1+='\u@\h \w \$ '
fi

for sh in /etc/bash/bashrc.d/* ; do
   [[ -r ${sh} ]] && source "${sh}"
done

# Try to keep environment pollution down, EPA loves us.
unset use_color sh


my /etc/bash/bashrc
Also if you have ~/.bashrc you have to check also that.
_________________
:)
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Thu Oct 07, 2021 4:17 pm    Post subject: Reply with quote

LemonadeLlama wrote:
Also I'm not sure what you mean by "Is your prompt emitting color control sequences" :?:
A basic prompt is not colored. A colored prompt is only colored because it includes escape sequences that the terminal interprets as a color change request, instead of printing them literally. If your prompt does not include those escape sequences, then it is not requesting the terminal use color. Run the below for a demonstration:
Code:
$ for a in {31..36}; do printf '\e[0;%sm%s\e[0;39m\n' "$a" "$a"; done
31
32
33
34
35
36
On my terminal, those numbers are each printed in distinct colors. Are they for you, or are they all the default color? If they come out in different colors, then your terminal understands how to do color, and your prompt isn't requesting it. Check the value of PS1 and/or PROMPT_COMMAND. If they come out all in the same color, then your terminal is ignoring color requests.
Back to top
View user's profile Send private message
LemonadeLlama
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2021
Posts: 101
Location: New Zealand

PostPosted: Sun Oct 10, 2021 4:32 am    Post subject: Reply with quote

All those numbers printed different colours for me.

This is what my values of PS1 and PROMPT_COMMAND are:
Code:

jamie@TuxBox ~ $ echo $PS1
\u@\h \w \$
jamie@TuxBox ~ $ echo $PROMPT_COMMAND

jamie@TuxBox ~ $


As you said, all the characters in PS1 are the same colour.
Back to top
View user's profile Send private message
LemonadeLlama
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2021
Posts: 101
Location: New Zealand

PostPosted: Sun Oct 10, 2021 4:36 am    Post subject: Reply with quote

alamahant wrote:

Also if you have ~/.bashrc you have to check also that.


What I showed you was what my ~/.bashrc file looks like. Here's what my /etc/bash/bashrc file looks like:
Code:

jamie@TuxBox ~ $ cat  /etc/bash/bashrc
# /etc/bash/bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output.  So make sure this doesn't display
# anything or bad things will happen !


# Test for an interactive shell.  There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]] ; then
   # Shell is non-interactive.  Be done now!
   return
fi

# Bash won't get SIGWINCH if another process is in the foreground.
# Enable checkwinsize so that bash will check the terminal size when
# it regains control.  #65623
# http://cnswww.cns.cwru.edu/~chet/bash/FAQ (E11)
shopt -s checkwinsize

# Disable completion when the input buffer is empty.  i.e. Hitting tab
# and waiting a long time for bash to expand all of $PATH.
shopt -s no_empty_cmd_completion

# Enable history appending instead of overwriting when exiting.  #139609
shopt -s histappend

# Save each command to the history file as it's executed.  #517342
# This does mean sessions get interleaved when reading later on, but this
# way the history is always up to date.  History is not synced across live
# sessions though; that is what `history -n` does.
# Disabled by default due to concerns related to system recovery when $HOME
# is under duress, or lives somewhere flaky (like NFS).  Constantly syncing
# the history will halt the shell prompt until it's finished.
#PROMPT_COMMAND='history -a'

# Change the window title of X terminals
case ${TERM} in
   [aEkx]term*|rxvt*|gnome*|konsole*|interix|tmux*)
      PS1='\[\033]0;\u@\h:\w\007\]'
      ;;
   screen*)
      PS1='\[\033k\u@\h:\w\033\\\]'
      ;;
   *)
      unset PS1
      ;;
esac

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.
# We run dircolors directly due to its changes in file syntax and
# terminal name patching.
use_color=false
if type -P dircolors >/dev/null ; then
   # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
   LS_COLORS=
   if [[ -f ~/.dir_colors ]] ; then
      eval "$(dircolors -b ~/.dir_colors)"
   elif [[ -f /etc/DIR_COLORS ]] ; then
      eval "$(dircolors -b /etc/DIR_COLORS)"
   else
      eval "$(dircolors -b)"
   fi
   # Note: We always evaluate the LS_COLORS setting even when it's the
   # default.  If it isn't set, then `ls` will only colorize by default
   # based on file attributes and ignore extensions (even the compiled
   # in defaults of dircolors). #583814
   if [[ -n ${LS_COLORS:+set} ]] ; then
      use_color=true
   else
      # Delete it if it's empty as it's useless in that case.
      unset LS_COLORS
   fi
else
   # Some systems (e.g. BSD & embedded) don't typically come with
   # dircolors so we need to hardcode some terminals in here.
   case ${TERM} in
   [aEkx]term*|rxvt*|gnome*|konsole*|screen|tmux|cons25|*color) use_color=true;;
   esac
fi

if ${use_color} ; then
   if [[ ${EUID} == 0 ]] ; then
      PS1+='\[\033[01;31m\]\h\[\033[01;34m\] \w \$\[\033[00m\] '
   else
      PS1+='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
   fi

   alias ls='ls --color=auto'
   alias grep='grep --colour=auto'
   alias egrep='grep -E --colour=auto'
   alias fgrep='grep -F --colour=auto'
else
   # show root@ when we don't have colors
   PS1+='\u@\h \w \$ '
fi

for sh in /etc/bash/bashrc.d/* ; do
   [[ -r ${sh} ]] && source "${sh}"
done

# Try to keep environment pollution down, EPA loves us.
unset use_color sh
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Sun Oct 10, 2021 4:02 pm    Post subject: Reply with quote

The terminal can produce colors. Your prompt is not telling it to produce colors. Your bashrc would enable that, if your $TERM were on the approved list and dircolors worked. What is your $TERM? What path does bash take through that bashrc file? It seems likely that use_color is false. Why does it get set that way?
Back to top
View user's profile Send private message
LemonadeLlama
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2021
Posts: 101
Location: New Zealand

PostPosted: Mon Oct 11, 2021 1:13 am    Post subject: Reply with quote

Hu wrote:
The terminal can produce colors. Your prompt is not telling it to produce colors. Your bashrc would enable that, if your $TERM were on the approved list and dircolors worked. What is your $TERM? What path does bash take through that bashrc file? It seems likely that use_color is false. Why does it get set that way?


My terminal is alacritty.

Code:

jamie@TuxBox ~ $ echo $TERM
alacritty


Also here's what I have for DIR_COLORS. I feel like this is the issue but I don't know how to fix it.

Code:

jamie@TuxBox ~ $ dircolors -b /etc/DIR_COLORS
LS_COLORS='';
export LS_COLORS
jamie@TuxBox ~ $
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Mon Oct 11, 2021 2:49 am    Post subject: Reply with quote

/etc/DIR_COLORS includes a list of terminals known to support color. On my system, alacritty is not on the list. If it is also absent on yours, that would explain this. What happens if you add alacritty to the list, then rerun the tests?
Back to top
View user's profile Send private message
LemonadeLlama
Tux's lil' helper
Tux's lil' helper


Joined: 26 May 2021
Posts: 101
Location: New Zealand

PostPosted: Mon Oct 11, 2021 2:53 am    Post subject: Reply with quote

Hu wrote:
/etc/DIR_COLORS includes a list of terminals known to support color. On my system, alacritty is not on the list. If it is also absent on yours, that would explain this. What happens if you add alacritty to the list, then rerun the tests?


Adding alacritty to the list fixed the problem. Thank you for helping out.
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21635

PostPosted: Mon Oct 11, 2021 3:47 am    Post subject: Reply with quote

If color works properly for alacritty, and the default DIR_COLORS with the default $TERM of alacritty does not enable color, please consider filing a bug to have the default DIR_COLORS changed, so that this works automatically for the next person.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum