Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #183583 > unrolled thread

Problem with colors in terminal

Started bysteve <dlist@bluewin.ch>
First post2017-07-12 10:10 +0200
Last post2017-07-12 16:40 +0200
Articles 8 — 4 participants

Back to article view | Back to linux.debian.user


Contents

  Problem with colors in terminal steve <dlist@bluewin.ch> - 2017-07-12 10:10 +0200
    Re: Problem with colors in terminal deloptes <deloptes@gmail.com> - 2017-07-12 11:10 +0200
      [Solved] Re: Problem with colors in terminal steve <dlist@bluewin.ch> - 2017-07-12 11:40 +0200
        Re: [Solved] Re: Problem with colors in terminal Sven Joachim <svenjoac@gmx.de> - 2017-07-12 13:10 +0200
          Re: [Solved] Re: Problem with colors in terminal Greg Wooledge <wooledg@eeg.ccf.org> - 2017-07-12 14:40 +0200
          Re: [Solved] Re: Problem with colors in terminal steve <dlist@bluewin.ch> - 2017-07-12 16:20 +0200
            Re: [Solved] Re: Problem with colors in terminal Sven Joachim <svenjoac@gmx.de> - 2017-07-12 16:30 +0200
              Re: [Solved] Re: Problem with colors in terminal steve <dlist@bluewin.ch> - 2017-07-12 16:40 +0200

#183583 — Problem with colors in terminal

Fromsteve <dlist@bluewin.ch>
Date2017-07-12 10:10 +0200
SubjectProblem with colors in terminal
Message-ID<u2kSE-5FA-55@gated-at.bofh.it>
Hi there,

Since the upgrade to Stretch, I don't have colors anymore in
xfce4-terminal (except for directories which are in blue).

But strange thing, I have them in xterm.

All the logic is in ~/.bashrc.

In xfce4-terminal:

env | grep -i color
LS_COLORS=
COLORTERM=truecolor
TERM=gnome-256color
LS_OPTIONS=--color=auto

env | grep -i term
COLORTERM=truecolor
TERM=gnome-256color


In xterm:

env | grep -i color
LS_COLORS=no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.tex=01;35:*.dvi=01;35:*.ps=01;32:*.pdf=01;32:*.jpg=00;35:*.jpeg=00;35:*.gif=00;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=00;35:*.mpeg=00;35:*.avi=00;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.flac=01;35:*.mp3=01;35:*.mpc=01;35:*.ogg=01;35:*.wav=01;35:*.csv=01;33:*.csv~=01;30:*.odt=01;35:*.txt=01;35:
TERM=gnome-256color
LS_OPTIONS=--color=auto

env | grep -i term
XTERM_SHELL=/bin/bash
XTERM_VERSION=XTerm(327)
TERM=gnome-256color
XTERM_LOCALE=fr_CH.utf8



We see that LS_COLORS is set in xterm but not in xfce4-terminal. I don't
understand why since both should read ~/.bashrc when executed.

Any ideas?

Thanks,
Steve

[toc] | [next] | [standalone]


#183584

Fromdeloptes <deloptes@gmail.com>
Date2017-07-12 11:10 +0200
Message-ID<u2lOF-6iL-17@gated-at.bofh.it>
In reply to#183583
steve wrote:

> We see that LS_COLORS is set in xterm but not in xfce4-terminal. I don't
> understand why since both should read ~/.bashrc when executed.
> 
> Any ideas?

I think .bashrc is read only if you use bash as login shell.
You can try bash --login and see if color works, or check if it is executed
as login shell

regards

[toc] | [prev] | [next] | [standalone]


#183585 — [Solved] Re: Problem with colors in terminal

Fromsteve <dlist@bluewin.ch>
Date2017-07-12 11:40 +0200
Subject[Solved] Re: Problem with colors in terminal
Message-ID<u2mhH-6sQ-11@gated-at.bofh.it>
In reply to#183584
Le 12-07-2017, à 11:05:22 +0200, deloptes a écrit :

>steve wrote:
>
>> We see that LS_COLORS is set in xterm but not in xfce4-terminal. I don't
>> understand why since both should read ~/.bashrc when executed.
>>
>> Any ideas?
>
>I think .bashrc is read only if you use bash as login shell.
>You can try bash --login and see if color works, or check if it is executed
>as login shell

You're my hero!

Trying 'bash --login' gave me colors. xfce4-terminal was treated as a
non-login interactive shell, and thus was not reading $HOME/.bashrc.

So I created a file $HOME/.bash_profile with the following in it:

[ -f "$HOME/.profile" ] && source "$HOME/.profile"
[ -f "$HOME/.bashrc" ] && source "$HOME/.bashrc"

Now if bash is started as an interactive login shell it will read the following
files:

    ~/.bash_profile
    ~/.profile
    ~/.bashrc

and if bash is started as an interactive non-login shell:

    ~/.bashrc

(one can read https://askubuntu.com/questions/132276/configure-gnome-terminal-to-start-bash-as-a-login-shell-doesnt-read-bashrc/132319 for more info)


I also had to change my TERM variable to xterm-color in order to work.

(Rem: I also tried to check the box for that option in the preferences, but
that didn't work)

Question remains on why this behaviour changed from Jessie -> Stretch.

Thanks a lot, this issue was driving me insane.

Best,
Steve

[toc] | [prev] | [next] | [standalone]


#183590 — Re: [Solved] Re: Problem with colors in terminal

FromSven Joachim <svenjoac@gmx.de>
Date2017-07-12 13:10 +0200
SubjectRe: [Solved] Re: Problem with colors in terminal
Message-ID<u2nGP-7sP-35@gated-at.bofh.it>
In reply to#183585
On 2017-07-12 11:29 +0200, steve wrote:

> Le 12-07-2017, à 11:05:22 +0200, deloptes a écrit :
>
>>steve wrote:
>>
>>> We see that LS_COLORS is set in xterm but not in xfce4-terminal. I don't
>>> understand why since both should read ~/.bashrc when executed.
>>>
>>> Any ideas?
>>
>>I think .bashrc is read only if you use bash as login shell.

It's the other way around, .bashrc is only read if bash is _not_ a login
shell.  Which is why many people source ~/.bashrc from ~/.bash_profile
(or ~/.bash_login, or ~/.profile) to get the same behavior, no matter if
the are running a login shell or not.

> Trying 'bash --login' gave me colors. xfce4-terminal was treated as a
> non-login interactive shell, and thus was not reading $HOME/.bashrc.

By the comment above, xfce4-terminal should have treated bash as a login
shell, however it does not do this in my experience.  Now I'm confused.

> I also had to change my TERM variable to xterm-color in order to work.

That's something you definitely don't want to do, xterm-color is for
_very_ ancient terminals.  Be prepared for misbehavior in curses
programs.

Is there a reason why you are deviating from the default
TERM=xterm-256color in xfce4-terminal?

Cheers,
       Sven

[toc] | [prev] | [next] | [standalone]


#183601 — Re: [Solved] Re: Problem with colors in terminal

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2017-07-12 14:40 +0200
SubjectRe: [Solved] Re: Problem with colors in terminal
Message-ID<u2p5T-8f8-13@gated-at.bofh.it>
In reply to#183590
On Wed, Jul 12, 2017 at 01:00:22PM +0200, Sven Joachim wrote:
> It's the other way around, .bashrc is only read if bash is _not_ a login
> shell.  Which is why many people source ~/.bashrc from ~/.bash_profile
> (or ~/.bash_login, or ~/.profile) to get the same behavior, no matter if
> the are running a login shell or not.

Correct.  Makes me suspect that one or more of the OP's terminal emulators
is using the "-ls" (or analogous) option to force the terminal to be
a login shell, the way some universities do.

The correct answer, as you said here, is to ensure that ~/.bash_profile
(or whatever is in use) sources ~/.bashrc.  This makes both login shells
and non-login shells behave correctly.

> That's something you definitely don't want to do, xterm-color is for
> _very_ ancient terminals.  Be prepared for misbehavior in curses
> programs.

If it's got colors at all, it's not _very_ ancient.

[toc] | [prev] | [next] | [standalone]


#183607 — Re: [Solved] Re: Problem with colors in terminal

Fromsteve <dlist@bluewin.ch>
Date2017-07-12 16:20 +0200
SubjectRe: [Solved] Re: Problem with colors in terminal
Message-ID<u2qEF-Q6-3@gated-at.bofh.it>
In reply to#183590
Le 12-07-2017, à 13:00:22 +0200, Sven Joachim a écrit :

>> I also had to change my TERM variable to xterm-color in order to work.
>
>That's something you definitely don't want to do, xterm-color is for
>_very_ ancient terminals.  Be prepared for misbehavior in curses
>programs.
>
>Is there a reason why you are deviating from the default
>TERM=xterm-256color in xfce4-terminal?

No, not really (all of this is far from being crystal clear to me). But
changing to TERM=xterm-256color doesn't show colors.

[toc] | [prev] | [next] | [standalone]


#183608 — Re: [Solved] Re: Problem with colors in terminal

FromSven Joachim <svenjoac@gmx.de>
Date2017-07-12 16:30 +0200
SubjectRe: [Solved] Re: Problem with colors in terminal
Message-ID<u2qOn-VU-39@gated-at.bofh.it>
In reply to#183607
On 2017-07-12 16:15 +0200, steve wrote:

> Le 12-07-2017, à 13:00:22 +0200, Sven Joachim a écrit :
>
>>> I also had to change my TERM variable to xterm-color in order to work.
>>
>>That's something you definitely don't want to do, xterm-color is for
>>_very_ ancient terminals.  Be prepared for misbehavior in curses
>>programs.
>>
>>Is there a reason why you are deviating from the default
>>TERM=xterm-256color in xfce4-terminal?
>
> No, not really (all of this is far from being crystal clear to me). But
> changing to TERM=xterm-256color doesn't show colors.

I wonder if you have an old version of dircolors somewhere which does
not support xterm-256color.  What do the following two commands print?

type dircolors
dircolors --version

Cheers,
       Sven

[toc] | [prev] | [next] | [standalone]


#183609 — Re: [Solved] Re: Problem with colors in terminal

Fromsteve <dlist@bluewin.ch>
Date2017-07-12 16:40 +0200
SubjectRe: [Solved] Re: Problem with colors in terminal
Message-ID<u2qY1-YW-5@gated-at.bofh.it>
In reply to#183608
Le 12-07-2017, à 16:27:16 +0200, Sven Joachim a écrit :

>> No, not really (all of this is far from being crystal clear to me). But
>> changing to TERM=xterm-256color doesn't show colors.
>
>I wonder if you have an old version of dircolors somewhere which does
>not support xterm-256color.  What do the following two commands print?
>
>type dircolors

dircolors is hashed (/usr/bin/dircolors)

>dircolors --version

dircolors (GNU coreutils) 8.26

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.user


csiph-web