Skip to content

Instantly share code, notes, and snippets.

@gdagley
Last active March 23, 2018 15:59
Show Gist options
  • Save gdagley/1284283 to your computer and use it in GitHub Desktop.
Save gdagley/1284283 to your computer and use it in GitHub Desktop.
#!/bin/bash
# prompt themeing
function current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
# Checks if there are commits ahead from remote
function git_prompt_ahead() {
if [[ -n $(git log origin/$(current_branch)...HEAD --right-only 2> /dev/null | grep '^commit') ]]; then
echo -e "$SCM_THEME_PROMPT_AHEAD"
fi
}
# Checks if there are commits available from remote
function git_prompt_behind() {
if [[ -n $(git log origin/$(current_branch)...HEAD --left-only 2> /dev/null | grep '^commit') ]]; then
echo -e "$SCM_THEME_PROMPT_BEHIND"
fi
}
#added TITLEBAR for updating the tab and window titles with the pwd
case $TERM in
xterm*)
TITLEBAR="\[\033]0;\w\007\]"
;;
*)
TITLEBAR=""
;;
esac
function prompt_command() {
# PS1="${TITLEBAR}${orange}${reset_color}${green}\w${bold_blue}\[\$(scm_prompt_info)\]${normal} "
PS1="${TITLEBAR}${green}\w ${yellow}$(scm_prompt_info) $(git_prompt_ahead)$(git_prompt_behind)${normal} "
}
# scm themeing
SCM_THEME_PROMPT_DIRTY=" ✗"
SCM_THEME_PROMPT_CLEAN=" ✓"
SCM_THEME_PROMPT_PREFIX="("
SCM_THEME_PROMPT_SUFFIX=")"
SCM_THEME_PROMPT_AHEAD="↑"
SCM_THEME_PROMPT_BEHIND="↓"
RVM_THEME_PROMPT_PREFIX="|"
RVM_THEME_PROMPT_SUFFIX="|"
safe_append_prompt_command prompt_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment