LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   Terminal Colors (https://www.linuxquestions.org/questions/debian-26/terminal-colors-622835/)

carlosinfl 02-21-2008 12:08 PM

Terminal Colors
 
I noticed on my new Lenny installation when I am using "Terminal" in Gnome, normally I have purple for directories, green for scripts, and white for files however for some reason on my user profile, everything is simply white...

Did they change some default setting? It was never like this before and I did a basic netinst of Lenny.

Screenshot

Anyone know how to change this to get normal colors?

When I login as root, I do have normal colors, so the issue seems to be something alone with my user account.

PMorph 02-21-2008 12:18 PM

Did you check the .bashrc?
There should be some lines that need to be uncommented to enable colour.

bullium 02-21-2008 01:38 PM

To elaborate on PMorph's comment, there is a hidden file in your home directory called '.bashrc'. If you run
Code:

username@hostname:~$ man bash
there is a section in there about the .bashrc file.

Below is the portion of my .bashrc file that enables color support in my terminal. I run Ubuntu so your should look almost exactly the same.

Code:

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='ls --color=auto --format=vertical'
    #alias vdir='ls --color=auto --format=long'
fi

Hope this helps.

slakmagik 02-21-2008 10:29 PM

Incidentally, you can supply a file to that dircolors invocation and define your own filetype coloring in it. Not a big deal and I'm sure it doesn't apply to you, but some people seem to think the 'normal colors' are the *only* colors. Seems like I've had people ask questions about the 'green' files when they mean 'executable'. ;)

deepclutch 02-21-2008 11:48 PM

For a Reference,below is my Debian Sid's ~/.bashrc :
Code:

localhost:/home/prakash# cat .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
PATH=$PATH:/sbin:/usr/sbin:

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color)
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    ;;
*)
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    ;;
esac

# Comment in the above and uncomment this below for a color prompt
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~}\007"'
    ;;
*)
    ;;
esac

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable color support of ls and also add handy aliases
if [ "$TERM" != "dumb" ]; then
    eval "`dircolors -b`"
    alias ls='ls --color=auto'
    #alias dir='ls --color=auto --format=vertical'
    #alias vdir='ls --color=auto --format=long'
fi

# some more ls aliases
alias ll='ls -l'
alias la='ls -A'
alias l='ls -CF'

# Some more alias to avoid making mistakes:
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
 
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
fi

#pulseaudio
if [ ! -e /tmp/.esd-${UID} ]; then
        ln -s /tmp/.esd /tmp/.esd-${UID}
fi

export FLASH_FORCE_PULSEAUDIO=1


bigrigdriver 02-22-2008 12:33 AM

Global color settings are in /etc/DIR_COLORS. You can copy that file in your home directory as .dir_colors to define your own color settings, which will override the global settings in /etc/DIR_COLORS.

You can define categories of files and the colors to display.
Example:

NORMAL 00 # global default, although everything should be something.
FILE 00 # normal file
DIR 01;34 # directory
LINK 00;36 # symbolic link
FIFO 40;33 # pipe
SOCK 01;35 # socket
DOOR 01;35 # door
BLK 40;33;01 # block device driver
CHR 40;33;01 # character device driver
ORPHAN 01;47;31;07 # symlink to nonexistent file

# source code (blue)
.c 07;47;34;00
.i 07;47;34;00
.ii 07;47;34;00
.m 07;47;34;00
.mi 07;47;34;00
.h 07;47;34;00
.cc 07;47;34;00
.cp 07;47;34;00
.cxx 07;47;34;00
.c++ 07;47;34;00
.C 07;47;34;00

# executables (bright green)
.cmd 01;32
.exe 01;32
.com 01;32
.bat 01;32
.btm 01;32
.dll 01;32

# archives or compressed
.tar 00;31
.tbz 00;31
.tgz 00;31
.rpm 00;31
.deb 00;31
.arj 00;31
.taz 00;31
.lzh 00;31
.zip 00;31
.zoo 00;31
.z 00;31
.Z 00;31
.gz 00;31
.bz2 00;31
.tb2 00;31
.tz2 00;31
.tbz2 00;31

# image formats
.avi 01;35
.bmp 01;35
.fli 01;35
.gif 01;35
.jpg 01;35
.jpeg 01;35
.mng 01;35
.mov 01;35
.mpg 01;35
.pcx 01;35
.pbm 01;35
.pgm 01;35
.png 01;35
.ppm 01;35
.tga 01;35
.tif 01;35
.xbm 01;35
.xpm 01;35
.dl 01;35
.gl 01;35

# sound formats
.aiff 00;32
.au 00;32
.mid 00;32
.mp3 00;32
.ogg 00;32
.voc 00;32
.wav 00;32

# log files
.log 07;37;40

# html, pdf, and ps files
.shtml 07;35;47;01
.html 07;35;47;01
.htm 07;35;47;01
.pdf 07;35;47;01
.ps 07;35;47;01

deepclutch 02-22-2008 03:06 AM

no /etc/DIR_COLORS in Debian :p may be /etc/bash.bashrc will help ;)

slakmagik 02-22-2008 04:41 AM

You can get a dump of the builtin configs with 'dircolors -p' and customize from there. And whatever file you pass to be 'eval'ed will work. So you don't have to worry about /etc/DIR_COLORS or ~/.dir_colors or whatever. My file's called ~/.lscolors.


All times are GMT -5. The time now is 05:35 PM.