Posts Tagged ‘terminal’

Fancy Mac (OS-x) Prompt

The Problem

Boring promt

The Fix

– Open a Terminal window.

– Edit your .profile or create a file like so vi ~/.profile

Add the following to the file:

alias vi=’vim’
4 alias ol=’ssh root@′
5 #alias cade=’ssh′
6 alias cade=’ssh′
7 alias oce=’ssh root@′
9 # colors
10 export CLICOLOR=1
11 export TERM=xterm-color
12 export LSCOLORS=gxgxcxdxbxegedabagacad  # cyan directories
13 export PS1=’\[33[01;32m\]\u@\h\[33[00m\]:\[33[01;36m\]\w\[33[00m\]\$ ‘

# Starts the extended vi when using vi
alias vi=’vim’
# Nice listing using ll
alias ll=’ls -Alhp’

export CLICOLOR=1
export TERM=xterm-color
# Information about the colors at the bottom of the article
export LSCOLORS=gxgxcxdxbxegedabagacad  # cyan directories
export PS1=’\[33[01;32m\]\u@\h\[33[00m\]:\[33[01;36m\]\w\[33[00m\]\$ ‘

This will make sure that you prompt will have ansi colors and look something like this:
freddy@svn:~/Documents$ ll drwxr-xr-x  17 freddy  staff   578B Feb 10  2008 cadechristian.com_project/ -rw-r--r--@  1 freddy  staff   112K Mar  1  2008 server.docx drwxrwxrwx   4 freddy  staff   136B Jan 28  2008 server_backup/ -rw-r--r--@  1 freddy  staff   559K Mar  3  2008 sunJVM-on-intel-multicoreservers.pdf -rw-r--r--@  1 freddy  staff   556K Mar  1  2008 tomcat_performance_tuning_20071015.ppt freddy@svn:~/Documents$ 

LSCOLOR information

These are the available ANSI colors:

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 

Note that the above are standard ANSI colors. The actual display may differ depending on the color capabilities of the terminal in use. The order of the attributes in the LSCOLORS variable is 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

They are set in pairs, foreground (f) then background (b), i.e. fbfbfbfbfbfbfbfbfbfbfb for all 11 settings. The default is exfxcxdxbxegedabagacad, i.e. blue foreground and default background for regular directories, black foreground and red background for setuid executables, etc.