Skip to content

Instantly share code, notes, and snippets.

@fontka
Created May 16, 2025 17:12
Show Gist options
  • Save fontka/a8f025f4c804012ef127f4a60dec962b to your computer and use it in GitHub Desktop.
Save fontka/a8f025f4c804012ef127f4a60dec962b to your computer and use it in GitHub Desktop.
#!/bin/sh
# USAGE:
# run 'todo' to search for TAGS recursively and open in quickfix
# redirect if you don't want to open VIM e.g. 'todo > cfile', 'todo | cat'
TAGS='TODO|FIXME|NOTE'
RMTABS_REGEX='s/\([0-9]\+:\)[\t| ]*/\1 /'
[ -t 1 ] && (
vim -q <(fd -t f | xargs grep -nHE "$TAGS" | sed "$RMTABS_REGEX") \
--cmd 'autocmd VimEnter * copen | bd2' # START WITH QUICKFIX WINDOW ONLY
# --cmd 'autocmd VimEnter * cw | wincmd b' # STARTS WITH FIRST MATCH BUFFER AND QUICKFIX
) || (
fd -t f | xargs grep -nHE $TAGS | sed "$RMTABS_REGEX"
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment