Contents

My Customized Bash Prompt

Contents

I love customizing stuffs to make them more functional or aesthetically pleasing. I customized my Bash prompt to achieve both.

Here is how it looks:

./custom_prompt.png

The color combination might not fit everyone’s taste, but I find this prompt to be better in some other ways.

Why

Here are a few reasons why I chose to customize the prompt this way:

  1. Clock: There is a 24 hour clock integrated to the terminal (yellow).
  2. Less clutter with two lines: you write your commands in the second line. This leaves your first line to have as long of a path as you need. (I find it cumbersome to work in the terminal when the relative path is long.)
  3. Readability: The colors signifying the (user@host), the (~/path), and the commands you write are different.

How

If you want exact same look as I have here, put this in your ~\.bashrc file:

1
2
3
4
function parse_git_branch {
   git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\[\e[01;33m\][\A] \[\e[01;35m\]\u@\h \[\e[01;92m\]\w \[\e[02;92m\]\$(parse_git_branch) \n \[\e[00;91m\]➜ "

If you want to experiment customizing your prompt, here are some good resources that I found useful:

  1. Bash tips: Colors and formatting
  2. Making bash prompt bold (askubuntu.com)