commit c58089fe317c090abeaa2247c1b63a194ef12c49
parent c10e8fe1aacaec7e30e07d1fec3b06752d249978
Author: William Casarin <jb55@jb55.com>
Date: Thu, 12 Nov 2020 12:05:11 -0800
fuzz cmdtree
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
8 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/bin/fuzz b/bin/fuzz
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+set -e
+
+file="$($FUZZER)"
+$@ "$file"
diff --git a/bin/fuzz-cd-dirname b/bin/fuzz-cd-dirname
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+exec fuzz dirname
diff --git a/bin/fuzz-edit-command b/bin/fuzz-edit-command
@@ -0,0 +1,2 @@
+#!/usr/bin/env bash
+file=$(cutt -f3 $HOME/dotfiles/commands | $FUZZER) && sedit "$file"
diff --git a/bin/fuzz-edit-command-list b/bin/fuzz-edit-command-list
@@ -0,0 +1,2 @@
+#!/usr/bin/env sh
+exec $EDITOR $HOME/dotfiles/commands
diff --git a/bin/fuzz-edit-scripts b/bin/fuzz-edit-scripts
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+# TODO: edit any script in path
+set -e
+file="$(ls -1 $HOME/bin | $FUZZER)"
+$EDITOR "$HOME/bin/$file"
diff --git a/bin/fuzz-run-command b/bin/fuzz-run-command
@@ -0,0 +1,9 @@
+#!/usr/bin/env bash
+res=$($FUZZER -q ^ < $HOME/dotfiles/commands) &&
+cmd=$(cutt -f3 <<<"$res")
+after=$(cutt -f4 <<<"$res")
+if [ -z "$after" ]; then
+ $cmd
+else
+ $after $($cmd)
+fi
diff --git a/dotfiles/.bash_aliases b/dotfiles/.bash_aliases
@@ -38,7 +38,7 @@ md () {
alias e="edit -n"
alias g=git
-alias c=cmdtree
+alias f=". fuzz-run-command"
alias vim=nvim
alias feh="feh --conversion-timeout 2"
alias info="info --vi-keys"
diff --git a/dotfiles/commands b/dotfiles/commands
@@ -0,0 +1,4 @@
+cd find directory fuzz-cd-dirname cd
+efcl edit fuzz command list fuzz-edit-command-list
+efc edit fuzz command fuzz-edit-command
+ec edit commands fuzz-edit-scripts