Skip to content

Instantly share code, notes, and snippets.

@claudiug
Forked from alepore/after_cd_ctags
Created March 14, 2014 09:27
Show Gist options
  • Save claudiug/9544673 to your computer and use it in GitHub Desktop.
Save claudiug/9544673 to your computer and use it in GitHub Desktop.
#!/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