13

I've tried everything from this duplicate question but I still can't get it to work. The only difference from that question is that when I run env | grep TERM I get TERM=xterm instead of TERM=xterm-color. I dont think it matters though, they seem to be pretty interchangeable.

What I don't understand however is that the only thing that has disappeared is the colors in the actual prompt. For example, if I run nano and it detects the syntax of the file, for example if it's a script, I get colors. Also when I run the env command mentioned earlier, the actual TERM text is red.

So the colors are obviously working, it's just that I don't get colored folders, executable files and so on anymore. I think it also might have occured in connection to installing Ruby/RVM. I've tried replacing .bashrc. (edit However, when creating a new user, that user has working colors)

I suppose this has a pretty simple solution but I'm just so sick of googling this now that I'd really appreciate som info on how the coloring settings works in the terminal and how this could happen. Thanks!

2 Answers 2

32

You do not have problems with your terminal or terminal setting. Try this:

ls --color

It works, doesn't it?

Most likely, you have replaced your .bashrc. You can find the original .bashrc, which for example defines the alias ls='ls --color=auto' and also color promtpts in /etc/skel/.

Copy a new .bashrc with:

mv ~/.bashrc ~/.bashrc.old
cp /etc/skel/.bashrc ~/.bashrc
4
  • I had an l alias in .bash_profile, so I changed that now to alias l='ls -l --color'. Typing l now gives me a colored list, but ls still lacks color, even though I've seen the .bashrc file specifically has an alias for it being colored. Ugh, thank you greatly for your answer though, I'll have to read some bash documentation.
    – pzkpfw
    Sep 29, 2012 at 12:10
  • 1
    ls (the default program) does not display colors unless you specify an option (--color=auto). If you want this to be the default behaviour, create an alias ls='ls --color=auto' (like most people do).
    – January
    Sep 29, 2012 at 12:20
  • Yeah, what bugs me though is that ls did show colors initially (I think it's the default in Ubuntu Server). Nevermind, now I know how to fix it :)
    – pzkpfw
    Sep 30, 2012 at 12:32
  • 1
    The default in /etc/skel/.bashrc is to set alias ls='ls --color=auto'
    – January
    Sep 30, 2012 at 15:20
2

On Ubuntu, in .bashrc there is a section that states:

# 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

So all that is needed is to uncomment the force_color_promp=yes

1
  • I would also suggest indicating to @pzkpfw to logout and login again to see the changes in action.
    – dgonzalez
    May 19, 2017 at 15:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .