citadel

My dotfiles, scripts and nix configs
git clone git://jb55.com/citadel
Log | Files | Refs | README | LICENSE

commit e0b0544f816d26ff1926297233cafc1bffecd7f3
parent 0b99ac0d7ee4ee6d4cc66c58fb663aa00eda9d38
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 13 Nov 2020 15:32:59 -0800

fuzz: more fuzz madness

Diffstat:
Abin/file-jump | 5+++++
Abin/fuzz-compile | 6++++++
Abin/fuzz-compile-error | 10++++++++++
Abin/fuzz-compile-repeat | 2++
Mbin/fuzz-edit-file | 2+-
Mbin/fuzz-edit-scripts | 3++-
Abin/fuzz-make | 7+++++++
Abin/fuzz-notmuch-archive | 7+++++++
Abin/fuzzer | 8++++++++
Abin/make-script | 16++++++++++++++++
10 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/bin/file-jump b/bin/file-jump @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +set -eou pipefail + +sed -n 's,^[[:space:]]*\([^:]\+\):\([0-9]\+\).*,edit "\1" +\2,p' diff --git a/bin/fuzz-compile b/bin/fuzz-compile @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +set -eou pipefail + +make_cmd=$(fuzz-make "$@") +echo $make_cmd \2\>\&\1\| tee .build-result diff --git a/bin/fuzz-compile-error b/bin/fuzz-compile-error @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -eou pipefail + +if [ ! -f .build-result ]; then + printf "no build result found\n" >&2 + exit 1 +fi + +<.build-result grep : | fuzzer "$@" | file-jump diff --git a/bin/fuzz-compile-repeat b/bin/fuzz-compile-repeat @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +tac ~/.fuzzhist | grep -E "make [^\w]+" | head -n1 diff --git a/bin/fuzz-edit-file b/bin/fuzz-edit-file @@ -1,4 +1,4 @@ #!/usr/bin/env bash set -e -file=$(rg --files "${1:-.}" | $FUZZER) +file=$(rg --files "${1:-.}" | fuzzer) echo $EDITOR \"$(readlink -f $file)\" diff --git a/bin/fuzz-edit-scripts b/bin/fuzz-edit-scripts @@ -1,5 +1,6 @@ #!/usr/bin/env bash # TODO: edit any script in path + set -e -file="$(ls -1 $HOME/bin | $FUZZER)" +file="$(ls -1 $HOME/bin | fuzzer "$@" )" echo $EDITOR "$HOME/bin/$file" diff --git a/bin/fuzz-make b/bin/fuzz-make @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -eou pipefail + +cmd=$(grep '^[^#[:space:]].*:' Makefile | grep -v PHONY | cut -d: -f1 | sort | fuzzer "$@") + +echo make $cmd diff --git a/bin/fuzz-notmuch-archive b/bin/fuzz-notmuch-archive @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set -eou pipefail + +threads=$(notmuch-inbox | $FUZZER -m | awk '{print $1}') + +echo notmuch tag -inbox $threads diff --git a/bin/fuzzer b/bin/fuzzer @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +arg=$1 + +if [ -n "$arg" ]; then + env FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --exit-0 --select-1 -q '$arg'" $FUZZER +else + $FUZZER +fi diff --git a/bin/make-script b/bin/make-script @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +set -e +name=$1 +if [ -z "$name" ]; then + printf 'make ~/bin/' + read name +fi + +if [ -z "$name" ]; then + exit 1 +fi + +$EDITOR ~/bin/$name +if [ -f ~/bin/$name ]; then + chmod +x ~/bin/$name +fi