Set Bash Shell Prompt to Color

Perm URL with updates: http://xahlee.org/linux/shell_color_prompt.html

Here's a neat setup for your bash shell. Put the following in your Bash init file 〔~/.bash_profile〕:

export PS1="\e[0;32m◆\u@\H \e[0;33m\D{%Y-%m-%d} \e[0;32m\t \e[0;37m\w\n";

The \e[0;32m in the beginning set the color green. The \e[0;37m near the end sets color back to black. (See: ANSI escape code.)

It'll make your prompt color green and display login name, date, and time, like this:

◆xah@xah-PC 2012-04-17 01:49:16 ~/.emacs.d/

Date and time is useful because when you log your shell output.

Emacs

For coloring bash prompt running inside emacs, put the following in your emacs init file.

(setenv "PS1" "\\e[0;32m◆\\u@\\H \\D{%Y-%m-%d} \\t\\e[0;30m\\w\\n")

Popular posts from this blog

11 Years of Writing About Emacs

does md5 creates more randomness?

Google Code shutting down, future of ErgoEmacs