Skip to content

Instantly share code, notes, and snippets.

@tecfu
Last active November 1, 2018 12:15
Show Gist options
  • Save tecfu/814e997098334e40698ffcbc0987f2a2 to your computer and use it in GitHub Desktop.
Save tecfu/814e997098334e40698ffcbc0987f2a2 to your computer and use it in GitHub Desktop.
Parse and output TODOs and FIXMEs from comments in your files

Parsing

ack/ag

$ ag --color --color-match 00 -Rio '@todo.*|@fixme.*' src

To save same output as STDOUT (when redirecting to file ag sends different output):

$ script --return -c "ag --color --color-match 00 -Rio '@todo.*|@fixme.*' src" TODO

To split ag's output into columns:

$ script --return -c "ag --color --color-match 00 -Rio '@todo.*|@fixme.*' src" | column -t -s @ > TODO

grep

$ grep --color=always -rni -E "@todo|@fixme" src/**/*.{js,vue} > TODO

To split grep's output into columns:

$ grep --color=always -rnio -E "@todo.*|@fixme.*" src/**/*.{js,vue} | column -t -s @ > TODO

Note:

In order to use *.{js,vue} syntax make sure bash has extglob set to 'on':

shopt -s extglob

Viewing

$ watch --color -n 1 -d cat TODO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment