Fancy Shell Prompts

Fancy shell prompts are not just pretty, they’re also incredibly practical. With the powerline prompt, you’ll always know what branch your working on, if there are any uncommitted changes and the exit code of the last command.

Powerline Shell (bash)

This is how to get a fancy shell prompt like the one below for the bash shell.

Example of Powerline Shell Prompt

Install powerline

We’ll use the powerline port for bash.

install-powerline.sh
git clone [email protected]:milkbikis/powerline-shell.git powerline-shell
cd powerline-shell/
./install.py

Configure Bashrc

Add the following to your ~/.bashrc file. Somewhere near the bottom will be perfect.

~/.bashrc
function _update_ps1() {
  PS1="$(~/powerline-shell/powerline-shell.py  --cwd-mode fancy --shell bash $? 2> /dev/null)"
}

if [ "$TERM" != "linux" ]; then
  PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

Install iTerm2

Go here: https://www.iterm2.com/downloads.html

Download & Install

Install font package

install-fonts.sh
git clone [email protected]:powerline/fonts.git powerline-fonts
cd powerline-fonts/
./install.sh