Another thing that I often do is "grep". I am known for that. I am comfortable with it and many times use it instead of ctags. One thing annoys me (or used to annoy me) is I have to remember C variable names to do a grep on it. I wanted to write a tab completion, using programmable bash completion feature, that searches into tag files and complete variable names in grep.
For example, in the current directory, you have a .c file with "int mynameisrumplestiltskin;". Now you want to grep through all the files for "mynameisrumplestiltskin". You should be able to do that with "grep myn[TAB]" and it should complete.
Today I found some time to do this. Turned out to be very easy. Just put following code in you bashrc file. Go ahead give it a try.
_grep()
{
local cur exp file
COMPREPLY=()
exp=${COMP_WORDS[1]}
file=${COMP_WORDS[2]}
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $(ls *.c *.h 2>/dev/null | ctags --filter=yes | awk '{print $1}' | grep ^$exp) )
fi
if [ $COMP_CWORD -gt 1 ]; then
COMPREPLY=( $( compgen -f -- "$file" ) $( compgen -d -- "$file" ) )
fi
}
complete -F _grep grep
Did it work?