Ubuntu – can’t enable prompt color in bash terminal

bashcommand line

I can't enable prompt color in my terminal (Ubuntu 14.04 LTS).

Here's my .bashrc:

force_color_prompt=yes
export LANGUAGE='en_US.UTF-8 git'

export HISTCONTROL=ignoreboth
#export HISTSIZE=100000
#export HISTFILESIZE=100000

# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
# Force prompt to write history after every command.
# http://superuser.com/questions/20900/bash-history-loss
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
# #########

# Some example functions
# function settitle() { echo -ne "\e]2;$@\a\e]1;$@\a"; }
export PATH=${PATH}:/home/louisro/android-sdk-linux/tools
export PATH=${PATH}:/home/louisro/android-sdk-linux/platform-tools
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
export PATH=${JAVA_HOME}/bin:$PATH
export PATH=/usr/local/bin:$PATH

export NVM_DIR="/home/louisro/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

Best Answer

I guess, you don't have set a colour to your prompt. You can do this with the following syntax: \e[x;ym $PS1 \e[m

\e[ : Start colour scheme.
x;y : Colour pair to use (x;y)
$PS1 : Your shell prompt variable.
\e[m : Stop colour scheme.

To set a red colour prompt, type the following command:

export PS1="\e[0;31m[\u@\h \W]\$ \e[m "

add it to your .bashrc to make it permanent.


Here is a list of available colours:

Colour  Code
Black   0;30
Blue    0;34
Green   0;32
Cyan    0;36
Red     0;31
Purple  0;35
Brown   0;33
Blue    0;34
Green   0;32
Cyan    0;36
Red     0;31
Purple  0;35
Brown   0;33

Note: You need to replace digit 0 with 1 to get light colour version. refer to this tutorial for more info. You may also take a look at this very good german explanation

Related Question