Skip to content

Instantly share code, notes, and snippets.

@FestivalBobcats
Created September 15, 2011 14:46
Show Gist options
  • Save FestivalBobcats/1219432 to your computer and use it in GitHub Desktop.
Save FestivalBobcats/1219432 to your computer and use it in GitHub Desktop.
gemopen() {
gem_dir=( $(find $GEM_HOME/gems -maxdepth 1 | grep $1) )
dir_count=${#gem_dir[*]}
if [ $dir_count == 0 ]; then
echo $1 directory not found.
elif [ $dir_count == 1 ]; then
mate ${gem_dir[0]}
else
for line in ${!gem_dir[*]}; do
echo $(($line + 1)). ${gem_dir[$line]}
done
echo -e '> \c'
read inpt
if [[ $inpt =~ [[:digit:]] ]]; then
dir=${gem_dir[$inpt - 1]}
if [ -d $dir ]; then
mate $dir
fi
fi
fi
}
# Add color support to ls
alias ls='ls -lhG'
gi() {
gem install $1 --no-rdoc --no-ri
}
# Removes all deleted files from current working tree
gitrm() {
git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached
}
__quiet() {
$1 2> /dev/null
}
parse_git_branch() {
__quiet 'git branch' | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
count_git_changes() {
count=$(__quiet 'git status -s' | wc -l)
if [ !$count == 0 ]; then
echo ' '$count
fi
}
export PS1='\[\e[0;34m\]\W\[\e[0m\]\[\e[0;36m\]$(parse_git_branch)\[\e[0;33m\]$(count_git_changes) \[\e[0;37m⚡\]\[\e[0m\] '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment