Customize your terminal prompt

July 16th, 2006 | Filed under Code snippets, Bash scripts

I’m probably going to be embarrassed about this post in the morning, but I re-figured out how to customize my terminal prompt, and I got something that I like which I’ll post here for the next time I get a new computer and have to Google the whole thing up again.

In ~/.bashrc (Mac: ~/.bash_profile), add:


function prompt
{
local GREEN="\[\033[0;32m\]"
local CYAN="\[\033[0;36m\]"
local GRAY="\[\033[0;37m\]"
local BLUE="\[\033[0;34m\]"
export PS1="${GREEN}\u${CYAN}@${BLUE}\h ${CYAN}\w${GRAY}
$ "
}
prompt

Then:


$ source .bashrc

Which makes it look something like this:


gina@amelia ~/Documents
$

But with pretty colors.

That is all.