Why does OS X terminal need manually sourcing to display colour?

I have the following in my ~/.bash_profile file:

export CLICOLOR=1
export PS1="$FBLU[\#]$RS--$RS{\t}$RS$FWHT\W$RS$FMAG@$RS$FRED\u$RS$FCYN\$$RS$FBLU>>>$RS"
# ANSI color codes
RS="\[\033[0m\]" # reset
HC="\[\033[1m\]" # hicolor
UL="\[\033[4m\]" # underline
INV="\[\033[7m\]" # inverse background and foreground
FBLK="\[\033[30m\]" # foreground black
FRED="\[\033[31m\]" # foreground red
FGRN="\[\033[32m\]" # foreground green
FYEL="\[\033[33m\]" # foreground yellow
FBLU="\[\033[34m\]" # foreground blue
FMAG="\[\033[35m\]" # foreground magenta
FCYN="\[\033[36m\]" # foreground cyan
FWHT="\[\033[37m\]" # foreground white
BBLK="\[\033[40m\]" # background black
BRED="\[\033[41m\]" # background red
BGRN="\[\033[42m\]" # background green
BYEL="\[\033[43m\]" # background yellow
BBLE="\[\033[44m\]" # background blue
BMAG="\[\033[45m\]" # background magenta
BCYN="\[\033[46m\]" # background cyan
BWHT="\[\033[47m\]" # background white

alias ls="ls -l"
function cd() { builtin cd "$@" && ls -l; }

When I open the terminal, I get:

[1]--{08:20:18}~@mike$>>>

which proves that the formatting is working. However, I am required to source the .bash_profile file every time the terminal runs in order for the colours to display correctly:

. ~/.bash_profile

Why is this happening? What can I do so that the colours display each time the terminal runs?

I am also running the Peppermint terminal style, although I am having the same problem without it - could this have something to do with it?


The color variables should be defined before the export PS1. Now, when you call $RS on that line, that variable is empty. Try this way:

export CLICOLOR=1

# ANSI color codes
RS="\[\033[0m\]" # reset
HC="\[\033[1m\]" # hicolor
UL="\[\033[4m\]" # underline
INV="\[\033[7m\]" # inverse background and foreground
FBLK="\[\033[30m\]" # foreground black
FRED="\[\033[31m\]" # foreground red
FGRN="\[\033[32m\]" # foreground green
FYEL="\[\033[33m\]" # foreground yellow
FBLU="\[\033[34m\]" # foreground blue
FMAG="\[\033[35m\]" # foreground magenta
FCYN="\[\033[36m\]" # foreground cyan
FWHT="\[\033[37m\]" # foreground white
BBLK="\[\033[40m\]" # background black
BRED="\[\033[41m\]" # background red
BGRN="\[\033[42m\]" # background green
BYEL="\[\033[43m\]" # background yellow
BBLE="\[\033[44m\]" # background blue
BMAG="\[\033[45m\]" # background magenta
BCYN="\[\033[46m\]" # background cyan
BWHT="\[\033[47m\]" # background white

export PS1="$FBLU[\#]$RS--$RS{\t}$RS$FWHT\W$RS$FMAG@$RS$FRED\u$RS$FCYN\$$RS$FBLU>>>$RS"

alias ls="ls -l"
function cd() { builtin cd "$@" && ls -l; }