Skip to content

Instantly share code, notes, and snippets.

@alepore
Last active December 18, 2015 04:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alepore/5727708 to your computer and use it in GitHub Desktop.
Save alepore/5727708 to your computer and use it in GitHub Desktop.
RVM hook for ctags and gemtags auto generation.put in ~/.rvm/hooks/, remember to chmod +x it
#!/usr/bin/env bash
function generate_tags {
(ctags -R -f .tags 2> /dev/null &)
}
function generate_gemtags {
(bundle show --paths | xargs ctags -R -f .gemtags 2> /dev/null &)
}
# if in a ruby project and ctags exists
if [ -f Gemfile ] && hash ctags
then
# if no tags
if [ ! -f .tags ]
then
echo 'Generating ctags...'
generate_tags
# if tags older than 3 days
elif test `find ".tags" -mmin +5000`
then
echo 'Updating ctags...'
generate_tags
fi
# if no gemtags
if [ ! -f .gemtags ]
then
echo 'Generating gemtags...'
generate_gemtags
# if gemtags older than Gemfile.lock
elif [ -f "Gemfile.lock" -a ".gemtags" -ot "Gemfile.lock" ]
then
echo 'Updating gemtags...'
generate_gemtags
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment