Skip to content

Instantly share code, notes, and snippets.

@joshwalsh
Created January 24, 2011 17:24
Show Gist options
  • Save joshwalsh/793566 to your computer and use it in GitHub Desktop.
Save joshwalsh/793566 to your computer and use it in GitHub Desktop.
PATH=$PATH:$HOME/bin
export EDITOR='mvim'
export GIT_EDITOR='mvim'
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
# Prompt Setup
source ~/.gittabcomplete
YELLOW='\[\e\033[1;33m\]'
BLUE='\[\e\033[1;34m\]'
GREEN='\[\e\033[1;32m\]'
RED='\[\e\033[0;31m\]'
NORMAL='\[\e\033[00m\]'
function minutes_since_last_commit {
now=`date +%s`
last_commit=`git log --pretty=format:'%at' -1`
seconds_since_last_commit=$((now-last_commit))
minutes_since_last_commit=$((seconds_since_last_commit/60))
echo $minutes_since_last_commit
}
git_prompt() {
local g="$(__gitdir)"
if [ -n "$g" ]; then
local MINUTES_SINCE_LAST_COMMIT=`minutes_since_last_commit`
if [ "$MINUTES_SINCE_LAST_COMMIT" -gt 40 ]; then
local COLOR=${RED}
elif [ "$MINUTES_SINCE_LAST_COMMIT" -gt 15 ]; then
local COLOR=${YELLOW}
else
local COLOR=${GREEN}
fi
local SINCE_LAST_COMMIT="${COLOR}$(minutes_since_last_commit)m${NORMAL}"
# The __git_ps1 function inserts the current git branch where %s is
local GIT_PROMPT=`__git_ps1 "(%s|${SINCE_LAST_COMMIT})"`
echo "${GIT_PROMPT}"
fi
}
PS1="\n[\W] \$(git_prompt) → "
# System
alias e='mvim'
alias ll='ls -la'
alias commit='git commit -a -m '
alias gx='gitx'
alias wip='cucumber --tags @wip'
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment