How to disable all syntax coloring in Cygwin/bash?

Gary Johnson garyjohn@spocom.com
Mon Dec 16 23:18:00 GMT 2013


On 2013-12-16, Chris Wolf wrote:

> On Mon, Dec 16, 2013 at 4:58 PM, Chris Wolf wrote:
> > I just installed a recent release of Cygwin and notice that it now
> > features syntax highlighting.  Is there a way to totally disable this?
> >  All I want is be able to set the foreground/background colors via the
> > Windoze way of right clicking on the frame and I don't want the out of
> > "ls" colorized nor for the colors to change to some weird settings
> > upon invoking "vi".  I want them the same under all conditions.
> >
> > I checked the documentation, FAQ and message archives of this list,
> > but most of the questions were about how to *enable* colors or
> > customize them.
> >
> > I actually did figure a round-about way of doing this via setting some
> > env vars and setting (or unsetting aliases).  Unfortunately the laptop
> > I did this on died, so I'm starting from scratch.
> >
> > (P.S. this could be bash issue and not exactly Cygwin, although older
> > releases of Cygwin did not have this "problem". )

> I was able to come up with something, though not sure it's the best or
> what I had before.  Sorry if this is obvious to most people, but to
> get rid of colorized output, I added to my .bashrc:
> 
> export LS_COLORS=''
> 
> If $PS1 has terminal color escape codes, then replace that also with
> something else, e.g.:
> 
> export PS1="\h $ "

There is no one way to enable or disable colors.  In Cygwin and
other Unix-like systems, each terminal application controls its use
of color by its own means, independently of other applications or
global settings.

Colored file names in the output of 'ls' are usually there because
your environment includes an alias for 'ls', "ls --color=auto".

Cygwin creates a default ~/.bashrc when user accounts are created by
copying /etc/defaults/etc/skel/.bashrc.  In my installation, though,
neither that file nor /etc/bash.bashrc contains an alias for 'ls',
so I don't know where yours is coming from.  In any case, you can
disable it by putting

    unalias ls

in your ~/.bashrc

As you've discovered, a colored prompt is generated by PS1.  PS1
defaults to something like "$ " but most distributions set it to
something more useful and prettier.  Cygwin does so in
/etc/bash.bashrc.  The fix for that is to define it yourself in your
~/.bashrc, as you have done.

The coloring used by 'vi' is determined by the configuration files
read by vi upon startup.  When compiled and installed from the
original sources on Unix, vi does not use colors.  To see what
configuration files 'vi' is reading, run "vi --version" and look for
the various vimrc files.  If your 'vi' is displaying colors, they
are being enabled in one of those configuration files.

You can't easily prevent 'vi' from reading those configuration
files, but you can unset their settings in your ~/.virc.  To get rid
of syntax highlighting,

    syntax off

should do it.

HTH,
Gary


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list