Command line colors
February 28, 2005 9:22 PM   Subscribe

Color in the Linux command line. My slackware 10 system uses contextual color for directory browsing, my RedHat 9 system uses it for vi. Both uses of color make life easier for me, but the difference between the two systems does not. Is there an easy way I can get both computers to use these colors?

Color vi is (I'm guessing) vim, but I can't find a slackware package for it and have pretty much no experience building such a thing myself. Don't recall installing it on purpose, as the RedHat system was set up a long time before I ever expected I'd be using command line much. Color for command line I have no clue about, seems to be the default for a slackware install. As I'm trying to teach myself command line I'm accessing these two computers only via putty / SSH, and the slackware system has no GUI installed to begin with. Any help would be appreciated.
posted by caution live frogs to Computers & Internet (15 answers total)
 
I've got a file on my linux system at /etc/DIR_COLORS that defines the color codes for certain filetypes. If you make sure both systems have this same file, perhaps that would sync them up?
posted by odinsdream at 9:39 PM on February 28, 2005


DIR_COLORS does match, and yet no colors. I'm using the exact same settings for PuTTY except for the hostname, so it's not that...
posted by caution live frogs at 10:15 PM on February 28, 2005


Are you using the same shell? (bash, tsch, etc.?)
posted by benzo8 at 10:46 PM on February 28, 2005


How do I get vi to NOT use colours? Colour coding makes it much more difficult for me to read non-proportional fonts.
posted by krisjohn at 12:00 AM on March 1, 2005


Dare I suggest emacs/Xemacs to a vi user?
posted by AlexReynolds at 12:19 AM on March 1, 2005


If you are using bash, use the command type ls to find out if ls is aliased to anything. On my Fedora Core 3 system, ls is actually 'ls --color=tty'. On my Cygwin system, ls is actually 'ls --color=auto --ignore-backups'.
posted by grouse at 12:47 AM on March 1, 2005


krisjohn: you could try:

:syntax off
posted by gi_wrighty at 2:47 AM on March 1, 2005


For the colored directory listing,



(Then you can alias ls so you don't have to type this every time). The syntax for setting the environment variable depends on your shell, of course, but this should work for you.

For vi, it depends on which implementation of vi you're using. If you have vim, or gvim, then :syntax enable should turn syntax coloring on.

Alex: no, the only point of that would be to call attention to yourself, which is not necessary here.
posted by Wolfdog at 3:15 AM on March 1, 2005


puTTY has colour settings to change the colours displayed. Change them in "Window -> Colours"
posted by ajbattrick at 4:43 AM on March 1, 2005


If you don't have vim on your slackware, bite the bullet, download the source and build it. It won't hurt a bit and you'll be quite pleased with yourself.
posted by Wolfdog at 5:57 AM on March 1, 2005


type and alias seemed to help me out the most here, thanks everyone. The slackware system was set up as
alias dir='ls $LS_OPTIONS --format=vertical'
alias ls='ls $LS_OPTIONS'

After I changed the aliases defined in .bashrc on the RedHat system the colors match.

As for vi, that was easy once I knew where to look - the RedHat system was set up as alias vi='vim'. Simple enough, never realized vim actually was already on the slackware box.

(Given the sudden drop in support by RedHat I'm really liking the slackware system more and more...)

And AlexReynolds... -bash: emacs: command not found :)
Not married to vi, it just happened to be the default text editor. Is emacs worth the trouble to learn one more set of commands?
posted by caution live frogs at 6:24 AM on March 1, 2005


Is emacs worth the trouble to learn one more set of commands?

I'm not married to emacs, and it is useful to know vi since it is on every UNIX system. Just that xemacs is highly extensible. I'd take a few minutes to learn its basics.
posted by AlexReynolds at 7:39 AM on March 1, 2005


caution, emacs is well worth the trouble, if you're going to spend any amount of time with a text editor.

You might want to take a look at debian as well: installing packages should not be a headache.
posted by cytherea at 8:07 AM on March 1, 2005


Set puTTY terminal to vt100 or color_xterm and change your TERM to match this. To remove colors in vim without doing it in vim every time create ~/.vimrc with this in it:

syntax off

For extra dorkiness here is my .vimrc, and pertinent portions of my .profile with an ANSI colored command line. (OpenBSD with colorls port, remove any line feeds ). I dig vim highlighting.

~/.bashrc:
TERM=color_xterm
EDITOR=/usr/local/bin/vim
PS1='\[\033[1;37m\][\[\033[1;34m\]\h\[\033[1;37m\]]\[\033[1;36m\]|\[
\033[1;37m\][\[\033[0;34m\]\u\[\033[1;37m\]]\n\[\033[0;37m\]\[
\033[1;35m\]\w\[\033[0m\]:'
#For Linux use
eval -b /'etc/DIR_COLORS'
alias ls='ls --color=auto'
#LSCOLORS=exHxgxGxExghehhEhHhGHEHG
#alias ls='/usr/local/bin/colorls -FG'


~/.vimrc:
set background=dark (use 16 colors instead of 8 in vim highlights)
syntax on
set hlsearch
set nocompatible
set autoindent
set smartindent
set tabstop=2
set shiftwidth=2
set showmatch
set ruler
set incsearch
posted by mnology at 9:55 AM on March 1, 2005


ed is the standard text editor.
posted by grouse at 2:28 AM on March 2, 2005


« Older Places to Stay in New Orleans   |   Stumped in Sudoku Newer »
This thread is closed to new comments.