3 # This file is responsible for setting up the pretty colours in GNU 'ls' and
4 # the bash prompt. Depending on whether you use a light on dark, or dark on
5 # light terminal you want different colour schemes. Rxvt and some other
6 # set the COLORFGBG environment variable to make autodetecting this easy.
8 # These scripts attempt to detect the terminal colours, and then set COLORFGBG
9 # if it isn't already set so that programs like vim can set the correct colours.
11 # If your terminal isn't detected correctly then you can run lightterm or
12 # darkterm to get the colours right. The default can be adjusted below.
14 # Set to 0 for light background terminal colours by default
15 # Set to 1 for dark background terminal colours by default
19 # Terminals that we want coloured prompts in
20 [ -n "${COLORTERM}" ] && PS1_COLOR=1
21 [ "${TERM}" = "linux" ] && DARK="${DARK:-1}"
22 [ "${TERM}" = "screen.linux" ] && DARK="${DARK:-1}"
23 [ "${TERM}" = "putty" ] && DARK="${DARK:-1}"
24 [ "${TERM}" = "cygwin" ] && DARK="${DARK:-1}"
25 [ "$(tput colors)" -gt 2 ] && PS1_COLOR=1
27 # Override COLORFGBG (probably used the darkterm or lightterm function
28 if [ -n "${DARK}" ]; then
35 # If COLORFGBG is set, use it to determine the terminal type, DARK=0 is
36 # dark on light, DARK=1 is light on dark.
37 if [ -n "${COLORFGBG}" ]; then
38 BG="$(echo "$COLORFGBG" | sed 's/.*;//')"
39 if ! [ "${BG}" -ge 0 ]; then
40 if [ "${BG}" = "white" ]; then
45 elif [ "${BG}" -ge 0 -a "${BG}" -le 6 -o "${BG}" -eq 8 ]; then
52 # Otherwise we just do our best based on the setting of DARK
53 if [ ${DARK} -eq 0 ]; then
54 export COLORFGBG="0;15"
56 export COLORFGBG="15;0"
61 [ -r /usr/share/git/completion/git-prompt.sh ] && source /usr/share/git/completion/git-prompt.sh
63 find_up_recurse .git || return
64 GIT_PS1_SHOWDIRTYSTATE=1 \
65 GIT_PS1_SHOWUNTRACKEDFILES=1 \
66 __git_ps1 2> /dev/null
70 find_up_recurse .hg || return
71 b="$(hg branch 2>/dev/null)" || return
72 s="$(hg status | cut -c1 | sort -u | tr -d " \n")"
74 [ -n "$s" ] && echo -n " $s"
79 find_up_recurse .svn || return
80 s="$(svn status --ignore-externals 2>/dev/null | cut -c1 | sort -u | tr -d " \n")"
85 # Set the prompt colour, and the colors for the 'ls' command appropriately,
86 # depending on the background of the terminal.
87 if [ ${PS1_COLOR:-0} -eq 1 ]; then
88 eval $(TERM=xterm dircolors 2> /dev/null)
90 if [ -z "$debian_chroot" -a -r /etc/debian_chroot ]; then
91 debian_chroot=$(cat /etc/debian_chroot)
93 PS1='${debian_chroot:+($debian_chroot)}'
94 PS1="$PS1"'\[\033[00;31m\]\u@\h\[\033[00m\]:\[\033[00;34m\]\w\[\033[00m\]'
95 PS1="$PS1"'\[\033[00;36m\]$(my_git_ps1 ; my_hg_ps1 ; my_svn_ps1)\[\033[00m\]'
98 if [ ${DARK} -eq 0 ]; then
99 LS_COLORS="$(echo "${LS_COLORS}" | sed 's/01;/00;/g')"
100 LSCOLORS="exfxcxdxbxegedabagacad" # BSD ls
102 # We need to bold the LS_COLORS and PS1 environment variables
103 # so they show up on a dark terminal
104 LS_COLORS="$(echo "${LS_COLORS}" | sed 's/00;/01;/g')"
105 LSCOLORS="ExFxCxDxBxEGEDABAGACAD" # BSD ls
106 PS1="$(echo "${PS1}" | sed 's/00;/01;/g')"