Skip to content

Instantly share code, notes, and snippets.

@rafaeldff
Created March 9, 2012 16:12
Show Gist options
  • Save rafaeldff/2007295 to your computer and use it in GitHub Desktop.
Save rafaeldff/2007295 to your computer and use it in GitHub Desktop.
Project status script
#! /bin/bash
function find_proj_from() {
if [[ $1 == '/' ]] || [[ -z $1 ]] ; then
return
fi
if [[ -e $1/.git ]]; then
FOUND_PROJ_AT=$1
return
fi
REST=`echo $1 | sed 's/\/[^/]*$//'`
find_proj_from $REST
}
function find_proj() {
find_proj_from `pwd`
PROJECT=`echo $FOUND_PROJ_AT | sed 's/^.*\/\([^/]\+\)$/\1/'`
}
echo '##### Status ####'
echo "You are at $(pwd). Today is $(date +'%Y-%m-%d')."
echo
echo '***** Project *****'
find_proj
if [[ ! -z $PROJECT ]] ; then
find_proj
echo "$PROJECT ($(cat $FOUND_PROJ_AT/version 2> /dev/null))";
fi
echo "RVM: $(rvm list 2> /dev/null | grep --color=NEVER '^=>')"
echo "RVM Gemset: $(rvm gemset list 2> /dev/null | grep --color=NEVER '^=>')"
echo
echo '***** Git Status *****'
timeout 2s git fetch &> /dev/null
[[ $? == 124 ]] && echo "(git fetch could not complete within 2 seconds)"
git status
echo
echo '***** Git History (last 3 commits) *****'
git log --pretty=format:"%ad |%C(yellow)%d%Creset| %s [%an]" --graph --date=short -n 3 | cat
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment