From 29be734fc088b79082ab1b4225b21286a47c7f8b Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Mon, 25 Aug 2014 01:17:56 -0400 Subject: [PATCH] Vastly improved the gentags script-- now uses either $PWD or input paths --- gentags | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/gentags b/gentags index c662fed..f47b122 100755 --- a/gentags +++ b/gentags @@ -1,3 +1,22 @@ #!/usr/bin/env bash -[[ `type -P ctags` ]] && ctags -R -f ~/.vim/tags /usr/include /usr/local/include $@ || echo "Can't find the ctags binary in $PATH" +TAGS_FILE="${HOME}/.vim/tags" +CTAGS_CMD="ctags --fields=+l --c-kinds=+p --c++-kinds=+p -R -f ${TAGS_FILE}" + +function generate_tags(){ + echo -e "\nRecursively generating tags for the following paths:" + for path in "$@"; do + echo " ${path}" + done + RESULT=$($CTAGS_CMD "$@" >/dev/null 2>&1) && echo -e "Done!\n" || echo -e "Failed! Look at ${TAGS_FILE}.log for details.\n" + if [[ -n "$RESULT" ]]; then + echo "$RESULT" >> "${TAGS_FILE}.log" + fi +} + +if [[ $(type -P ctags) ]]; then + [[ -n "$1" ]] && generate_tags "$@" || generate_tags "$PWD" +else + echo 'Error: cannot find the ctags binary in $PATH' + exit 1 +fi