Bash Color Chart

OS/리눅스 & 유닉스 2012. 3. 16. 18:36

 http://www.arwin.net/tech/bash.php 

#!/bens/bash

This is a collection of bash environment settings and useful information that I like to keep handy for when I'm setting up a new shell environment.

It's an ever-growing work in progress that I add to as I discover new customizations (and have the time to document them).

My main focus here is customizing the colors in bash prompts and in 'ls' output. I'm a fairly visual person, so I like different systems to have different colors in their prompts. It's helpful when you have several ssh sessions open across multiple machines and want to easily identify which machine you're looking at. Reboot the wrong machine once or twice and you start to appreciate the visual hints :)

Bash Color Chart(back to top)

Black 0;30 Dark Gray 1;30 Blue 0;34 Light Blue 1;34 Green 0;32 Light Green 1;32 Cyan 0;36 Light Cyan 1;36 Red 0;31 Light Red 1;31 Purple 0;35 Light Purple 1;35 Brown 0;33 Yellow 1;33 Light Gray 0;37 White 1;37

Bash Prompts(back to top)

Two Line Prompt

# with time export PS1='\n\[\e[31;1m\]CWD\[\e[0m\]:\[\e[36;1m\]\w\n\[\e[32;1m\]\@:\u@\h\[\e[0m\]\$ ' # without the time: export PS1='\n\[\e[31;1m\]CWD\[\e[0m\]:\[\e[36;1m\]\w\n\[\e[32;1m\]\u@\h\[\e[0m\]\$ '

black and red

export PS1='\[\033[1;31m\](\[\033[0;37m\]\u\[\033[1;31m\]@\h\[\033[1;31m\]:\[\033[1;36m\]\w\[\033[1;31m\])\[\033[1;36m\]\$ \[\033[0;37m\]' # alternate for root, same but green username: export PS1='\[\033[1;32m\](\[\033[1;32m\]\u\[\033[1;31m\]@\h\[\033[1;31m\]:\[\033[1;36m\]\w\[\033[1;32m\])\[\033[1;36m\]\$ \[\033[0;37m\]'

ubuntu

# ubuntu sets a pretty nice prompt by default (if you have a TERM=xterm-color (I modified the \w to be purple (35) instead of blue (34) export PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;35m\]\w\[\033[00m\]\$ '

Smiley Face Prompt

# smiley face prompt: # From: CommandLineFu PS1="\`if [ \$? = 0 ]; then echo \e[33\;40m\\\^\\\_\\\^\e[0m; else echo \e[36\;40m\\\-\e[0m\\\_\e[36\;40m\\\-\e[0m; fi\` \u \w:\h) "

Window/Tab Titles for terminal emulators (works with iTerm in OS X)

# If this is an xterm set the title to user@host:dir case "$TERM" in xterm*|rxvt*) PS1="\[\e]0;\u@\h: \w\a\]$PS1" ;; *) ;; esac

This was borrowed from a standard .bashrc on Ubuntu. It's more efficient than setting $PROMPT_COMMAND and it sends the appropriate escape codes to iTerm to set the tab title.

Without this, if you ssh to a remote machine that sets a title, that title will stick around even after your ssh session has ended. Meaning you'll be back on your local machine but the tab/window title will still reflect the last remote machine you were logged in to. Confusing...

Dir Colors(back to top)

Linux

# LS_COLORS (make directories purple instead of dark blue . The rest are what ubuntu shipped w/by default) LS_COLORS='no=00:fi=00:di=01;35:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:su=37;41:sg=30;43:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.flac=01;35:*.mp3=01;35:*.mpc=01;35:*.ogg=01;35:*.wav=01;35:'; export LS_COLORS
Show Extra

Mac OS X (BSD)

# Dir colors (barwin custom) # http://www.mactips.org/archives/2005/08/02/color-your-os-x-command-prompt/ # http://www.macosxhints.com/article.php?story=20031025162727485 export CLICOLOR=1 export LSCOLORS=FxFxCxDxBxegedabagacad

Aliases(back to top)

alias ll='ls -la' alias cd..='cd ..' alias vi=vim alias svi='sudo vi' alias vis='vim "+set si"' alias apt-get="sudo apt-get" alias rm='rm -i' alias mv='mv -i' alias cp='cp -i' alias sha1='openssl sha1' alias grep='grep --color=auto'

Valid XHTML 1.0 Transitional

Valid CSS!

'OS > 리눅스 & 유닉스' 카테고리의 다른 글

아파치 접속자 수  (0) 2012.03.20
ANSI Escape Sequences: Colours and Cursor Movement  (0) 2012.03.16
IBM nmon FAQ  (0) 2012.03.16
Unix Programming Frequently Asked Questions  (0) 2012.03.16
UNIX 명령어  (0) 2012.03.16
: