Skip to content

Instantly share code, notes, and snippets.

@hansek hansek/colorful.theme.bash

Last active Feb 21, 2017
Embed
What would you like to do?
# Bash-it theme inspired by theme "Sexy" and "Bobby" themes
# https://gist.github.com/hansek
if [[ $COLORTERM = gnome-* && $TERM = xterm ]] && infocmp gnome-256color >/dev/null 2>&1; then
export TERM=gnome-256color
elif [[ $TERM != dumb ]] && infocmp xterm-256color >/dev/null 2>&1; then
export TERM=xterm-256color
fi
if [ -t 1 ]; then
COLOR_ENV=$(tput setaf 9)
COLOR_USER=$(tput setaf 172)
COLOR_HOST=$(tput setaf 33)
COLOR_PATH=$(tput setaf 190)
COLOR_GIT=$(tput setaf 141)
COLOR_BOLD=$(tput bold)
COLOR_DEFAULT=$(tput sgr0)
else
COLOR_ENV=$red
COLOR_USER=$yellow
COLOR_HOST=$blue
COLOR_PATH=$green
COLOR_GIT=$purple
COLOR_BOLD=$normal
COLOR_DEFAULT=$reset_color
fi
VIRTUALENV_THEME_PROMPT_PREFIX="(\[$COLOR_ENV\]"
VIRTUALENV_THEME_PROMPT_SUFFIX="\[$COLOR_DEFAULT\]) "
function prompt_command() {
# This needs to be first to save last command return code
local RC="$?"
# Set return status color
if [[ ${RC} == 0 ]]; then
ret_status=$bold_green
else
ret_status=$bold_red
fi
# Append new history lines to history file
history -a
PS1="\t $(virtualenv_prompt)\[$COLOR_USER\]\u\[$COLOR_DEFAULT\] at \[$COLOR_HOST\]\h\[$COLOR_DEFAULT\] in \[$COLOR_PATH\]\w\[$COLOR_DEFAULT\]\[$COLOR_GIT\]\$(__git_ps1) ${ret_status}» \[$COLOR_DEFAULT\]"
}
safe_append_prompt_command prompt_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.