commit cd4b9f54918af9cdabaf8ecd813587bc642f7136
parent 3dd57b9e4749eb431d83b3a22bfd92555eabae62
Author: William Casarin <jb55@jb55.com>
Date: Sat, 14 Nov 2020 15:57:21 -0800
FUZZ NOTMUCH FUN
Diffstat:
21 files changed, 87 insertions(+), 22 deletions(-)
diff --git a/bin/fuzz-edit-command b/bin/fuzz-edit-command
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
set -e
-res=$(<$HOME/dotfiles/commands $FUZZER)
+res=$(<$HOME/dotfiles/commands fuzzer "$@")
echo sedit "$(cutt -f3 <<<$res)"
diff --git a/bin/fuzz-get-hist b/bin/fuzz-get-hist
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
set -e
fuzz-compress-hist
-cmd=$(<$HOME/.fuzzhist $FUZZER --tac)
-echo echo \"$cmd\"
+cmd_=$(<$HOME/.fuzzhist $FUZZER --tac)
+printf "echo \"%s\"\n" "$cmd_"
diff --git a/bin/fuzz-notmuch-archive b/bin/fuzz-notmuch-archive
@@ -2,6 +2,9 @@
set -eou pipefail
-threads=$(notmuch-inbox | $FUZZER -m | awk '{print $1}')
+thread_search=$(fuzz-notmuch-query-thread)
+
+threads=$(eval "$thread_search")
+fuzz-record-command "$thread_search | xargs notmuch tag -inbox"
echo notmuch tag -inbox $threads
diff --git a/bin/fuzz-notmuch-archive-messages b/bin/fuzz-notmuch-archive-messages
@@ -0,0 +1,7 @@
+#!/usr/bin/env bash
+
+set -eou pipefail
+
+ids=$(eval "$(fuzz-notmuch-query-messages)")
+
+echo notmuch tag -inbox $ids
diff --git a/bin/fuzz-notmuch-inbox b/bin/fuzz-notmuch-inbox
@@ -1,9 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-res=$(notmuch-inbox | $FUZZER +m)
-
-thread=$(awk '{print $1}' <<<"$res")
-
-echo notmuch show $thread \| notmuch-show-pretty \| less
diff --git a/bin/fuzz-notmuch-messages b/bin/fuzz-notmuch-messages
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+set -eou pipefail
+
+search_id=$(fuzz-notmuch-query-messages)
+
+rest="notmuch-show-pretty | less"
+id=$(eval "$search_id")
+fuzz-record-command "$search_id | xargs notmuch show | $rest"
+
+echo "notmuch show $id | $rest"
diff --git a/bin/fuzz-notmuch-process-query b/bin/fuzz-notmuch-process-query
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+echo "res=\$($1) && <<<\"\$res\" $FUZZER +m"
diff --git a/bin/fuzz-notmuch-query b/bin/fuzz-notmuch-query
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+set -eou pipefail
+
+query=$(notmuch queries | fuzzer "^query:")
+echo notmuch search "$@" "$query"
diff --git a/bin/fuzz-notmuch-query-messages b/bin/fuzz-notmuch-query-messages
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+set -eou pipefail
+
+search_query=$(fuzz-notmuch-query --output=summary --format=json)
+echo "$search_query | jq -rcC '.[] | [.date_relative,.subject,.authors,.query[0]] | @tsv' | $FUZZER -m | cutt -f4"
diff --git a/bin/fuzz-notmuch-query-thread b/bin/fuzz-notmuch-query-thread
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+set -eou pipefail
+
+search_query=$(fuzz-notmuch-query --output=summary --format=json)
+echo "$search_query | jq -rcC '.[] | [.date_relative,.subject,.authors,.thread] | @tsv' | $FUZZER -m | cutt -f4 | sed 's,^,thread:,g'"
diff --git a/bin/fuzz-notmuch-threads b/bin/fuzz-notmuch-threads
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+set -eou pipefail
+
+thread_search=$(fuzz-notmuch-query-thread)
+
+rest="notmuch-show-pretty | less"
+thread=$(eval "$thread_search")
+fuzz-record-command "res=\$($thread_search) && <<<\$res xargs notmuch show | $rest"
+echo "notmuch show $thread | $rest"
diff --git a/bin/fuzz-recent-files b/bin/fuzz-recent-files
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+set -eou pipefail
+recent-files | fuzzer "$@"
diff --git a/bin/fuzz-record-command b/bin/fuzz-record-command
@@ -0,0 +1,8 @@
+#!/usr/bin/env bash
+set -eou pipefail
+fhist="$HOME/.fuzzhist"
+touch "$fhist"
+cmd="$@"
+if [ -n "$cmd" ]; then
+ echo "$cmd" >> "$fhist"
+fi
diff --git a/bin/fuzz-run-command b/bin/fuzz-run-command
@@ -13,11 +13,9 @@ function runner() {
res=$($FUZZER +i --select-1 --exit-0 -q ^$prefix < $HOME/dotfiles/commands) &&
get_cmd=$(cutt -f3 <<<"$res") || return
get_cmd="$get_cmd $@"
- fhist="$HOME/.fuzzhist"
- touch "$fhist"
cmd="$(eval $get_cmd)"
+ fuzz-record-command "$cmd"
if [ -n "$cmd" ]; then
- echo "$cmd" >> "$fhist"
eval $cmd
fi
}
diff --git a/bin/notmuch-inbox b/bin/notmuch-inbox
@@ -1,2 +0,0 @@
-#!/usr/bin/env bash
-exec notmuch search "$@" tag:inbox and not tag:filed
diff --git a/bin/notmuch-messages b/bin/notmuch-messages
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+notmuch query
diff --git a/bin/notmuch-queries b/bin/notmuch-queries
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+notmuch config list | grep ^query | cut -d. -f2- | cut -d= -f1 | sed 's,^,query:,g'
diff --git a/bin/notmuch-query b/bin/notmuch-query
@@ -0,0 +1,4 @@
+#!/usr/bin/env bash
+set -eou pipefail
+query=$(notmuch queries | $FUZZER)
+echo notmuch search "$@" "$query"
diff --git a/bin/notmuch-threads b/bin/notmuch-threads
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+set -eou pipefail
+
+notmuch query | $FUZZER
+<<<"$threads" $FUZZER +m | awk '{print $1}'
diff --git a/bin/recent-files b/bin/recent-files
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+exec grep ^edit ~/.fuzzhist
diff --git a/dotfiles/commands b/dotfiles/commands
@@ -1,5 +1,6 @@
cd change directory fuzz-cd-dirname
-ef edit file fuzz-edit-file
+pf edit file fuzz-edit-file
+rf recent files fuzz-recent-files
eFl edit fuzz command list fuzz-edit-command-list
eFc edit fuzz command fuzz-edit-command
sFc show fuzz command fuzz-show-fuzz-command
@@ -11,7 +12,7 @@ cr compile repeat fuzz-compile-repeat
ce compile error fuzz-compile-error
cs compile show build echo cat .build-result
m make fuzz-make
-sf search files fuzz-search-files
+sp search project fuzz-search-files
Sr systemd restart fuzz-systemd-restart
Ss systemd start fuzz-systemd-start
SS systemd stop fuzz-systemd-stop
@@ -19,5 +20,8 @@ h run fuzz hist fuzz-run-hist
H get fuzz hist fuzz-get-hist
tj tag jump fuzz-tag-jump
gb git branches echo git-bvr
-ni notmuch inbox fuzz-notmuch-inbox
-na notmuch archive fuzz-notmuch-archive
+nt notmuch threads fuzz-notmuch-threads
+nm notmuch messages fuzz-notmuch-messages
+nat notmuch archive threads fuzz-notmuch-archive
+nam notmuch archive messages fuzz-notmuch-archive-messages
+nq notmuch query fuzz-notmuch-query