Skip to content

Instantly share code, notes, and snippets.

@zessx
Last active March 15, 2017 16:55
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 zessx/eeeac15ab0801c50fa3158af9b97adde to your computer and use it in GitHub Desktop.
Save zessx/eeeac15ab0801c50fa3158af9b97adde to your computer and use it in GitHub Desktop.
Search for single line TODOs in your project
#!/bin/bash
# Usage:
# ./todo.sh
# ./todo.sh folder1 folder2/subfolder
FOLDERS='./'
if [[ $* ]]; then
FOLDERS=$*
fi
RED='\033[1;31m'
GREEN='\033[1;32m'
NC='\033[0m'
SED_BLUE=`echo -e '\033[0;34m'`
SED_GREEN=`echo -e '\033[1;32m'`
SED_NC=`echo -e '\033[0m'`
GREP_PARAMS="-s -r -i --exclude todo.sh --exclude-dir node_modules --exclude-dir vendor todo ${FOLDERS}"
if [[ $(grep ${GREP_PARAMS}) ]]; then
echo -e "${RED}TODO list:${NC}"
grep -n ${GREP_PARAMS} | sed -r "s/(.+):(.+):.*todo\s*:?\s*(.*)/$SED_BLUE\1 $SED_GREEN\(line \2\) $SED_NC\3/I" | sed 's/#}//' | sed 's/*\///'
else
echo -e "${GREEN}TODO list empty.${NC}"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment