Skip to content

Instantly share code, notes, and snippets.

@tpope
Created May 5, 2016 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tpope/d41de7bf97ede2d372466e44ce0fbe1b to your computer and use it in GitHub Desktop.
Save tpope/d41de7bf97ede2d372466e44ce0fbe1b to your computer and use it in GitHub Desktop.
Ctags git hook
#!/bin/sh
set -e
if [ -d doc -a \( -d autoload -o -d ftdetect -o -d plugin \) ]; then
nohup vim -u NONE -c 'helptags doc' -cq >/dev/null 2>&1 </dev/null &
fi
optfiles=`git ls-files -oc --directory -- .ctags '*/.ctags'`
IFS='
'
for optfile in ${optfiles:-./fake}; do
(
unset GIT_DIR GIT_WORK_TREE
tmpfile=`mktemp ${TMPDIR:-/tmp}/tags.XXXXXXXXXX~`
cd `dirname $optfile`
trap 'rm -f $tmpfile' EXIT INT TERM
git ls-files | ctags -L - -f $tmpfile "$@"
mv $tmpfile tags
)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment