Add included files to your ctags file

To add the headers to the ctags file I found this little gem. And I ended up using it like this:

if [ ! -z $1 ];then

gcc -M ${root_path}/* 2> /dev/null | \
  sed -e 's/^ //' -e 's/ \\$//g' | \
  sed -e '/^$/d' -e '/\.o:[ \t]*$/d' | \
  sed -e 's/^.*\.o: //' -e 's/ /\n/g' | \
  cat - <(ls -d ${root_path}/*) | \
  ctags-universal -R -L - --c-kinds=+p --fields=+iaS --extras=+q

# -e 's/^ //'         -> Remove the first space
# -e 's/ \\&//g       -> Remove the training '\'
# -e '/^$/d'          -> Remove empty lines
# -e '/\.o:[ \t]*$/d' -> Remove the lines that have object file paths
# -e 's/^.*\.o: //'   -> Remove the object path from the line
# -e 's/ /\n/g' | \   -> Separate several source files with a return
# cat - <(ls -d ${root_path}/*) -> Append the root_path files

I’m still missing the implementation of the header files though. for another day…

About joelgranados

I'm fascinated with how technology and science impact our reality and am drawn to leverage them in order to increase the potential of human activity.
This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s