Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@BH1SCW
Forked from xuhdev/ctags_with_dep.sh
Created September 6, 2021 07:57
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 BH1SCW/d2e44847f7ad2fdf80503f5a32b36ed1 to your computer and use it in GitHub Desktop.
Save BH1SCW/d2e44847f7ad2fdf80503f5a32b36ed1 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