yoursweater
yoursweater

Reputation: 2041

I can't get colors in my shell prompt (iTerm)

I'm running Bash with iTerm on a Mac OS X and for some reason I can't seem to customize the colors in my prompt. I'm editing my .bashrc and here's what I've got in there at the moment:

ls --color=always
export LS_COLORS='rs=0:di=01;34:ln=01;36:mh=00:pi=40;33'
PS1='\e[33;1m\u@\h: \e[31m\W\e[0m\$ '


export TERM=xterm-color
export GREP_OPTIONS='--color=auto' GREP_COLOR='1;32'
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad

export COLOR_NC='\e[0m' # No Color
export COLOR_WHITE='\e[1;37m'
export COLOR_BLACK='\e[0;30m'
export COLOR_BLUE='\e[0;34m'
export COLOR_LIGHT_BLUE='\e[1;34m'
export COLOR_GREEN='\e[0;32m'
export COLOR_LIGHT_GREEN='\e[1;32m'
export COLOR_CYAN='\e[0;36m'
export COLOR_LIGHT_CYAN='\e[1;36m'
export COLOR_RED='\e[0;31m'
export COLOR_LIGHT_RED='\e[1;31m'
export COLOR_PURPLE='\e[0;35m'
export COLOR_LIGHT_PURPLE='\e[1;35m'
export COLOR_BROWN='\e[0;33m'
export COLOR_YELLOW='\e[1;33m'
export COLOR_GRAY='\e[0;30m'
export COLOR_LIGHT_GRAY='\e[0;37m'

In theory that should at least do SOMETHING. Does anyone have an idea as to why I'm not able to get these colors to appear (even after quitting and reloading)?

Upvotes: 2

Views: 1283

Answers (2)

Cam_Aust
Cam_Aust

Reputation: 2789

In OSX 10.11.x bash and Terminal, the file accessed eg with PS1 prompt coding etc, is the .bash_profile, not .bashrc. Could this be the source of the issue with iTerm?

When I customize my prompt, it is the .bash_profile that I edit.

However take note of the comment by – user1934428

If I remember right, you can configure in iTerm, what shell is executed, and how it is executed, so there is no general rule. Since there is a difference in interactive login-shells and interactive non-login-shells, a common practice is to put all commands which make sense in an interactive shell only, neither into .bashrc nor into .bash_profile, but into a separate file, which is sourced from both .bashrc and .bash_profile. Another option is to put it into .bashrc and to source .bashrc from .bash_profile.

You may also want to put some backslash-squarebracket around your non printing characters in your PS1 to avoid poor wrapping in Terminal, and possibly iTerm. See https://stackoverflow.com/questions/11831296/os-x-terminal-text-stacking-on-top-of-itself.

Upvotes: 1

Carl
Carl

Reputation: 90

It's possible that your terminal is loading its configuration from a different file, perhaps the default .bashrc, which I believe is in /etc. It's also possible that the terminal isn't using .bashrc at all and instead .Xresources or .Xdefaults.

Upvotes: 0

Related Questions