I finally decided to spend a little time tweaking terminal, and I thought I'd share some of what I came up with.
1) Display files in color:
- man ls will show you all of this, but I'll summarize
- Use the G option with ls. I put an alias for ls in my ~/.profile that looks like this:
l = Long Format
G = Colorize output
h = human readable file sizes
F = Displays various characters after certain file types such as a / after directories.
2) To modify the default colors for files, add to your ~/.profile:
** This is the default Mac Terminal Color Set
Change ex fx cx dx bx eg ed ab ag ac ad as follows:
* The first byte is the foreground color, the second byte is the background color.
ex = 1. Directory: blue/default
fx = 2. Symbolic Link: magenta/default
cx = 3. Socket: green/default
dx = 4. Pipe: brown/default
bx = 5. Executable: red/default
eg = 6. Block Special: blue/cyan
ed = 7. Character Special: blue/brown
ab = 8. Executable with setuid: black/red
ag = 9. Executable with setgid: black/cyan
ac = 10. Directory o+w with S bit: black/green
ad = 11. Directory o+w w/o S bit: black/brown
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
D bold brown, usually shows up as yellow
E bold blue
F bold magenta
G bold cyan
H bold light grey; looks like bright white
x default foreground or background
3) Customize your bash prompt:
This is normally a tricky endeavor due to escape sequences and syntax, so I've made it a little easier with some variables in .profile I found the titlebar and user color here. I just added the rest of the colors so you can select what you want, and expanded on his basic prompt a bit. The following goes in ~/.profile of course.
The following is the result of this work. The prompt shows:
As a regular user, the username and hostname are Bold Green
As the root user, the username and hostname are Bold Red
The title bar of the window shows the username, host and current path
Dark Grey Date \A
Bright Green Username \u
Bright Green Hostname \h
Dark Grey Current Session Command Count \#
Yellow Path \w (I use the / to finish it off)
I left the default directory colors alone except for changing the directories from Blue to Bold Blue.
Enjoy,
J
1) Display files in color:
- man ls will show you all of this, but I'll summarize
- Use the G option with ls. I put an alias for ls in my ~/.profile that looks like this:
Code:
alias dir='ls -lGhF'
l = Long Format
G = Colorize output
h = human readable file sizes
F = Displays various characters after certain file types such as a / after directories.
2) To modify the default colors for files, add to your ~/.profile:
Code:
LSCOLORS='exfxcxdxbxegedabagacad' ; export LSCOLORS
Change ex fx cx dx bx eg ed ab ag ac ad as follows:
* The first byte is the foreground color, the second byte is the background color.
ex = 1. Directory: blue/default
fx = 2. Symbolic Link: magenta/default
cx = 3. Socket: green/default
dx = 4. Pipe: brown/default
bx = 5. Executable: red/default
eg = 6. Block Special: blue/cyan
ed = 7. Character Special: blue/brown
ab = 8. Executable with setuid: black/red
ag = 9. Executable with setgid: black/cyan
ac = 10. Directory o+w with S bit: black/green
ad = 11. Directory o+w w/o S bit: black/brown
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
D bold brown, usually shows up as yellow
E bold blue
F bold magenta
G bold cyan
H bold light grey; looks like bright white
x default foreground or background
3) Customize your bash prompt:
This is normally a tricky endeavor due to escape sequences and syntax, so I've made it a little easier with some variables in .profile I found the titlebar and user color here. I just added the rest of the colors so you can select what you want, and expanded on his basic prompt a bit. The following goes in ~/.profile of course.
Code:
ENDCOLOR="\[\e[0m\]"
BLACK="\[\e[0;30m\]"
BLUE="\[\e[0;34m\]"
GREEN="\[\e[0;32m\]"
CYAN="\[\e[0;36m\]"
RED="\[\e[0;31m\]"
PURPLE="\[\e[0;35m\]"
BROWN="\[\e[0;33m\]"
GREY="\[\e[0;37m\]"
DGREY="\[\e[1;30m\]"
YELLOW="\[\e[1;33m\]"
WHITE="\[\e[1;37m\]"
B_BLUE="\[\e[1;34m\]"
B_GREEN="\[\e[1;32m\]"
B_CYAN="\[\e[1;36m\]"
B_RED="\[\e[1;31m\]"
B_PURPLE="\[\e[1;35m\]"
case $(id -u) in
0)
# STARTCOLOR='\[\e[31m\]';
STARTCOLOR=$B_RED;
;;
*)
# STARTCOLOR='\[\e[36m\]';
STARTCOLOR=$B_GREEN;
;;
esac
case $TERM in
xterm*)
TITLEBAR='\[\e]0;\u@\h \w \007\]';
;;
*)
TITLEBAR="";
;;
esac
PS1="[$DGREY\A $STARTCOLOR\u$GREY@$STARTCOLOR\h$GREY] <$DGREY\# $YELLOW\w/$GREY> $GREY$TITLEBAR"
The following is the result of this work. The prompt shows:
As a regular user, the username and hostname are Bold Green
As the root user, the username and hostname are Bold Red
The title bar of the window shows the username, host and current path
Dark Grey Date \A
Bright Green Username \u
Bright Green Hostname \h
Dark Grey Current Session Command Count \#
Yellow Path \w (I use the / to finish it off)
I left the default directory colors alone except for changing the directories from Blue to Bold Blue.
Enjoy,
J