Colorize your Csh or Bourne shell. Bourne shells include sh(1), ksh variants (Korn shells), and zsh(1). csh(1) is a different kind of shell which uses a different syntax for commands.
Environment
Environment values can be added to your shell configuration file(s). These variables for Bourne shells can be set in $HOME/.profile. sh, zsh and variant ksh Posix Bourne shells can read from these files. Bash can also use these files, but it has variations in its more specific customization files.
Csh uses many of the same basic variables as Bourne shells, but the syntax incorporating them is different. This shell uses .cshrc for customization.
To enable some configurations for sh, the following can be run from the commandline.
This can also be added to the configuration file. Then, restart the shell. Other Bourne shells reference a different configuration file.
Changing colors of ls output
The environment value
ls(1):
Different shells set these variables in different ways. Csh uses
.cshrc
.zshrc
Setting prompt colors
To set up your prompt in csh, use:
The colors go within the bracket parenthesis
In this example,
In my setup, the directories of the
adds the user name with colors to indicate that. This is useful for when indicating root on the console. Jail name can also be displayed on the prompt in a similar way.
zsh uses
More
Examples of csh and zshrc configurations can be viewed and shared on: Thread share-your-tcshrc-file.21040 and Thread share-your-zshrc-file.62653. For a related thread on Csh, see: Thread howto-color-files-by-extension-in-tcsh.29669. For a guide on Zsh: https://zsh.sourceforge.io/Guide/zshguide02.html.
.shrc and .kshrc were a bit more challenging to set up. There are scarce examples or instructions for these on the forums. There are also not as many examples of these on the Internet as other shells. More on colorizing Bourne shells can be added below.
More on colorizing Bourne shells, Csh or information that's closely related to the subject is welcome to be added to this thread.
This is unrelated to colorizing, but
For Bash, see: Thread colorize-your-bash-like-linux.45006.
Environment
Environment values can be added to your shell configuration file(s). These variables for Bourne shells can be set in $HOME/.profile. sh, zsh and variant ksh Posix Bourne shells can read from these files. Bash can also use these files, but it has variations in its more specific customization files.
Csh uses many of the same basic variables as Bourne shells, but the syntax incorporating them is different. This shell uses .cshrc for customization.
set
can be used to see basic variables from bourne shells, and csh. For csh, setenv
can be used to see its additional variables. export
is used from sh, ksh variants, and zsh. These commands are typed without arguments to view their variables, which can be adjusted. These same commands and additional arguments can be used to set these variables. Bourne shells vary in how their variables are set. echo
with $ and the specific variable written in capital letters can also be used to see that variable from your shell.To enable some configurations for sh, the following can be run from the commandline.
Code:
ENV=$HOME/.shrc; export ENV
Changing colors of ls output
The environment value
LSCOLORS
refers to the color output for ls(1) in the terminal. This value be added to your shell configuration file(s).ls(1):
Code:
LSCOLORS The value of this variable describes what color to
use for which attribute when colors are enabled with
CLICOLOR or COLORTERM. This string is a
concatenation of pairs of the format fb, where f is
the foreground color and b is the background color.
Code:
The color designators are as follows:
a black
b red
c green
d brown
e blue
f magenta
g cyan
h light grey
A bold black, usually shows up as dark grey
B bold red
C bold green
...
Code:
The order of the attributes are as follows:
1. directory
2. symbolic link
3. socket
4. pipe
5. executable
6. block special
7. character special
8. executable with setuid bit set
9. executable with setgid bit set
10. directory writable to others, with sticky
bit
11. directory writable to others, without
sticky bit
Code:
The default is "exfxcxdxbxegedabagacad", i.e., blue
foreground and default background for regular
directories, black foreground and red background for
setuid executables, etc.
CLICOLOR
sets this from the shell's configuration file, so ls -G
or its alias
aren't needed. COLORTERM
and TERM
are mentioned as similar in function to CLICOLOR
.Different shells set these variables in different ways. Csh uses
setenv
, and Zsh uses export
for setting these. Here's examples for Csh and Zsh:.cshrc
Code:
setenv LSCOLORS "gx"
setenv CLICOLOR
Code:
export LSCOLORS=ex
export CLICOLOR
LSCOLORS
is for basic ANSI colors. LS_COLORS is an alternative variable with a different syntax that comes with more colors, but it's available with certain shells: this variable can be found in the manpages of shells that use it. An example of this variable:
Code:
LS_COLORS='di=32:ln=35:so=33:pi=31:ex=34:bd=34;40:cd=35;40:su=30;42:sg=37;42:tw=30;46:ow=31;46'
Setting prompt colors
To set up your prompt in csh, use:
set prompt=
with the variables within double quotes. Variables within .cshrc are prefixed with %
.The colors go within the bracket parenthesis
{}
, prefixed with %
. \33
is the character escape, so the next variables can be used. Within that is an ANSI variable for colors. [x;xxm%
Code:
set prompt = "%{\033[1;36m%}%~ %{\033[0m%}%# "
[36;m%
and [0m%
are ANSI code for colors. %~
is used to show the current directory.In my setup, the directories of the
ls
output and in the prompt have nearly the same color. I adjusted the color, so it can contrast to a dark background.
Code:
set prompt = "%{\033[1;33m%}%N:%{\033[1;36m%}%~ %{\033[0m%}%# "
zsh uses
PS1=
for setting the prompt. PS2=
is for the prompt, when the shell is waiting on an interactive response. Some have used, PROMPT=
for setting the prompt in zsh. For color variables, zsh uses the word names, that are within %F{
}
and end enclosed by %f
.More
Examples of csh and zshrc configurations can be viewed and shared on: Thread share-your-tcshrc-file.21040 and Thread share-your-zshrc-file.62653. For a related thread on Csh, see: Thread howto-color-files-by-extension-in-tcsh.29669. For a guide on Zsh: https://zsh.sourceforge.io/Guide/zshguide02.html.
.shrc and .kshrc were a bit more challenging to set up. There are scarce examples or instructions for these on the forums. There are also not as many examples of these on the Internet as other shells. More on colorizing Bourne shells can be added below.
More on colorizing Bourne shells, Csh or information that's closely related to the subject is welcome to be added to this thread.
This is unrelated to colorizing, but
autoload -U history-search-end
can be added to .zshrc for auto completion.For Bash, see: Thread colorize-your-bash-like-linux.45006.