Skip to content

Instantly share code, notes, and snippets.

@Lu-Yi-Hsun
Forked from xuhdev/ctags_with_dep.sh
Created May 26, 2018 12:03
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 Lu-Yi-Hsun/e270bf9fa327c8d7d50357fd708f32d3 to your computer and use it in GitHub Desktop.
Save Lu-Yi-Hsun/e270bf9fa327c8d7d50357fd708f32d3 to your computer and use it in GitHub Desktop.
Generate ctags file for C or C++ files and its depedencies (included header files). This could avoid you to always generate a huge tags file.
#!/bin/sh
# https://www.topbug.net/blog/2012/03/17/generate-ctags-files-for-c-slash-c-plus-plus-source-files-and-all-of-their-included-header-files/
# ./ctags_with_dep.sh file1.c file2.c ... to generate a tags file for these files.
gcc -M "$@" | sed -e 's/[\\ ]/\n/g' | \
sed -e '/^$/d' -e '/\.o:[ \t]*$/d' | \
ctags -L - --c++-kinds=+p --fields=+iaS --extra=+q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment