Skip to content

Instantly share code, notes, and snippets.

@trekdemo
Created September 22, 2016 07:30
Show Gist options
  • Save trekdemo/51792e706192ffbd1607b26a90e1748a to your computer and use it in GitHub Desktop.
Save trekdemo/51792e706192ffbd1607b26a90e1748a to your computer and use it in GitHub Desktop.
Setup ctags with git

Create a folder to store git hook templates

# ~/.gitconfig

[init]
  templatedir = ~/.git_templates

The following files are in ~/.git_templates/hooks/

  • ctags
  • post-*
# ~/.ctags
--javascript-kinds=cm
--fields=-s
--languages=-html
--exclude=*.min.js
--exclude=jquery.*.js
--exclude=jquery-*.js

--exclude=.git
--exclude=build
--exclude=tmp
--exclude=log

--langdef=coffee
--langmap=coffee:.coffee
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=.*->.*$/\1/f,function/
--regex-coffee=/^[ \t]*([A-Za-z.]+)[ \t]+=[^->\n]*$/\1/v,variable/

--langdef=markdown
--langmap=markdown:.markdown
--regex-markdown=/^#[ \t]+(.*)/\. \1/h,heading1/
--regex-markdown=/^##[ \t]+(.*)/\.\. \1/h,heading2/
--regex-markdown=/^###[ \t]+(.*)/\.\.\. \1/h,heading3/
#!/bin/sh
set -e
PATH="/usr/local/bin:$PATH"
trap "rm -f .git/tags.$$" EXIT
ctags --tag-relative -Rf.git/tags.$$ --exclude=.git --languages=-javascript,sql
mv .git/tags.$$ .git/tags
#!/bin/sh
.git/hooks/ctags >/dev/null 2>&1 &
#!/bin/sh
.git/hooks/ctags >/dev/null 2>&1 &
#!/bin/sh
.git/hooks/ctags >/dev/null 2>&1 &
#!/bin/sh
.git/hooks/ctags >/dev/null 2>&1 &
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment