#! bash # This file is responsible for setting up the pretty colours in GNU 'ls' and # the bash prompt. It also sets COLORFGBG to give programs like vim an idea # of the terminal colours to use. If your terminal isn't detected correctly # then you can run lightterm or darkterm to get the colours right. To do this # automatically try changing the table below. # Terminals that we want coloured prompts in [ -n "${COLORTERM}" ] && PS1_COLOR=1 [ "${TERM}" = "linux" ] && PS1_COLOR=1 && DARK=1 [ "${TERM}" = "screen" ] && PS1_COLOR=1 [ "${TERM}" = "xterm" ] && PS1_COLOR=1 [ "${TERM}" = "xterm-color" ] && PS1_COLOR=1 [ "${TERM}" = "rxvt" ] && PS1_COLOR=1 [ "${TERM}" = "rxvt-unicode" ] && PS1_COLOR=1 # Override COLORFGBG (probably used the darkterm or lightterm function if [ -n "${DARK}" ]; then unset COLORFGBG fi # If COLORFGBG is set, use it to determine the terminal type, DARK=0 is # dark on light, DARK=1 is light on dark. if [ -n "${COLORFGBG}" ]; then FGCOLOR=$(echo "${COLORFGBG}" | cut -d ';' -f 1) BGCOLOR=$(echo "${COLORFGBG}" | cut -d ';' -f 3) if [ "${FGCOLOR}" -gt "${BGCOLOR}" ]; then DARK=1 fi unset FGCOLOR unset BGCOLOR else # Otherwise we just do our best based on the setting of DARK, defaulting to # light on dark, change the :-0 here to :-1 to change the default. if [ ${DARK:-0} -eq 0 ]; then export COLORFGBG="0;default;15" else export COLORFGBG="15;default;0" fi fi # Set the prompt colour, and the colors for the 'ls' command appropriately, # depending on the background of the terminal. if [ ${PS1_COLOR:-0} -eq 1 ]; then eval $(dircolors 2> /dev/null) PS1='\[\033[00;31m\]\u@\h\[\033[00m\]:\[\033[00;34m\]\w\[\033[00m\]\$ ' if [ ${DARK:-0} -eq 0 ]; then LS_COLORS="$(echo "${LS_COLORS}" | sed 's/01;/00;/g')" else # We need to bold the LS_COLORS and PS1 environment variables # so they show up on a dark terminal LS_COLORS="$(echo "${LS_COLORS}" | sed 's/00;/01;/g')" PS1="$(echo "${PS1}" | sed 's/00;/01;/g')" fi export LS_COLORS unset PS1_COLOR unset DARK fi