Skip to content

Instantly share code, notes, and snippets.

@wolever
Last active November 12, 2015 22:26
Show Gist options
  • Save wolever/76dec6618b80336a0dae to your computer and use it in GitHub Desktop.
Save wolever/76dec6618b80336a0dae to your computer and use it in GitHub Desktop.
Create tags for Django templates and management commands (so I can jump to a template with `:tag base.html`)
#!/bin/bash
IFS="`printf "\n\t"`"
set -eu
cd "$(dirname "$0")"
srcdir="akindi/"
ctags -R \
--exclude='*/lib/*' \
--exclude='*/vendor/*' \
--exclude='*/dist/*' \
--exclude='*/node_modules/*' \
--exclude="*/bower_components/*" \
"$srcdir"
# Create tags file entries for Django templates and management commands. For example:
#base.html akindi/dashboard/templates/dashboard/base.html 1
#base.html akindi/templates/base.html 1
#base.html akindi/templates/email/base.html 1
#cleanup.py akindi/home/management/commands/cleanup.py 1
find "$srcdir" \
-name node_modules -prune -or \
-name bower_modules -prune -or \
-type f -and \
'(' -path '*/templates/*' -and -not -name '.*' ')' -or \
'(' -path '*/management/commands/*' -and -name '*.py' -and -not -name '__init__.py' ')' | \
awk -F/ '{ printf("%s\t%s\t1\n", $NF, $0) }' >> tags
sort tags -o tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment