Skip to content

Instantly share code, notes, and snippets.

@kissofjudase23
Created March 7, 2019 02:59
Show Gist options
  • Save kissofjudase23/2e68e0797b878e30284ad3f2588cd096 to your computer and use it in GitHub Desktop.
Save kissofjudase23/2e68e0797b878e30284ad3f2588cd096 to your computer and use it in GitHub Desktop.
#!/bin/bash
DIR_LIST=( "${PWD}" )
function Generate_DB_File() {
Clean_DB_File
echo "<<Start to generate database for ctags and cscope!>>"
#create ctag data base
for dir in ${DIR_LIST[@]}
do
cd ${dir}
#create ctags db files
ctags -R --c++-kinds=+p --fields=+iaS --extra=+q .
#create cscope db files
find . -name "*.h"\
-o -name "*.hpp" \
-o -name "*.c" \
-o -name "*.cpp" \
-o -name "*.py" \
>cscope.files
cscope -Rbkq -i cscope.files
cd -
done
echo "<<Finished!>>"
}
function Clean_DB_File() {
echo "<<Clean cTag and cscope database files>>"
#create ctag data base
for dir in ${DIR_LIST[@]}
do
cd $dir
rm tags cscope*
cd -
done
echo "<<Clean database Finished!>>"
}
function main() {
echo "option is \"${1}\""
case "${1}" in
make)
Generate_DB_File
;;
clean)
Clean_DB_File
;;
*)
echo "usage example ${0} {make/clean}"
;;
esac
}
option=${1}
main ${option}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment