Skip to content

Instantly share code, notes, and snippets.

@hansek
Last active February 21, 2017 09:33
Show Gist options
  • Save hansek/99d7c8e90fc922f8642964edc7d494ca to your computer and use it in GitHub Desktop.
Save hansek/99d7c8e90fc922f8642964edc7d494ca to your computer and use it in GitHub Desktop.
# 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