commit d01a5189cf87ac90fd567209315b9efbf7dfc7fc parent 781cba532a27048ff61257a2123ad217cae72e4d Author: Ed van Bruggen <ed@edryd.org> Date: Wed, 4 Jun 2025 00:48:48 -0400 bash: Replace todo alias with shell script - Script now uses git grep if inside git repo - Also strips text around TODO note Diffstat:
| M | bashrc | | | 1 | - |
| A | bin/todo | | | 17 | +++++++++++++++++ |
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/bashrc b/bashrc @@ -162,7 +162,6 @@ alias f='feh --force-aliasing --auto-zoom --auto-rotate --scale-down' alias py='python3 -q' alias ipy='ipython --no-autoindent' alias exif='identify -verbose' # TODO only get exif info -alias todo='grep -RI TODO * --exclude-dir=public' # TODO use git grep if in git repo alias gg='git grep --untracked' alias dock-run='docker run -it --rm --detach-keys='ctrl-e,e' -v $PWD:$PWD -w $PWD' alias fonts-reload='fc-cache -f -v' diff --git a/bin/todo b/bin/todo @@ -0,0 +1,17 @@ +#!/bin/sh + +# todo: list TODOs in current directory +# +# TODO support FIX HACK WARNING etc +# TODO optionally include file and line number at end +# TODO include code if inline comment + +# Select grep to use: if in git repo use git grep, or regular grep if not +if git -C . rev-parse 2>/dev/null; then + SEARCH_CMD="git grep TODO *" +else + SEARCH_CMD="grep -RI TODO *" +fi + +# Run search and trim everything around the note +eval $SEARCH_CMD | sed -n -e 's/^.*TODO[ \t:]*//p' | sed -e 's@\*/$@@'