Skip to content

Instantly share code, notes, and snippets.

@isRuslan
Created February 1, 2017 07:44
Show Gist options
  • Save isRuslan/8eeb303ca2357b529842878787c2666a to your computer and use it in GitHub Desktop.
Save isRuslan/8eeb303ca2357b529842878787c2666a to your computer and use it in GitHub Desktop.
generate ctags
#!/usr/bin/env bash
set -e
# ctags doesn't handle negative look behinds so instead this script
# strips false positives out of a tags file.
ctags "$@"
FILE="tags"
while [[ $# > 1 ]]
do
key="$1"
case $key in
-f)
FILE="$2"
shift
;;
esac
shift
done
# Filter out false matches from class method regex
sed -i '' -E '/^(if|switch|function|module\.exports|it|describe) .+language:js$/d' $FILE
# Filter out false matches from object definition regex
sed -i '' -E '/var[ ]+[a-zA-Z0-9_$]+[ ]+=[ ]+require\(.+language:js$/d' $FILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment