citadel

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

commit 4fa9b72aae49be831d98d2f2c4b2a75f97d5f658
parent 35f93725d66a4650de9bf1a4cbacf9fbfc1567f7
Author: William Casarin <jb55@jb55.com>
Date:   Thu, 12 Nov 2020 14:39:49 -0800

fuzz: update to support new style

Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mbin/fuzz-cd-dirname | 4++--
Mbin/fuzz-edit-command | 2+-
Mbin/fuzz-edit-command-list | 2+-
Abin/fuzz-edit-file | 4++++
Mbin/fuzz-edit-scripts | 2+-
Mbin/fuzz-run-command | 26++++++++++++++++++--------
Abin/fuzz-run-hist | 6++++++
Abin/fuzz-show-fuzz-command | 2++
Abin/fuzz-show-script | 2++
Abin/fuzz-tag-jump | 2++
10 files changed, 39 insertions(+), 13 deletions(-)

diff --git a/bin/fuzz-cd-dirname b/bin/fuzz-cd-dirname @@ -1,2 +1,2 @@ -#!/usr/bin/env sh -exec fuzz dirname +#!/usr/bin/env bash +file="$(fuzz dirname)" && echo "cd \"$file\"" diff --git a/bin/fuzz-edit-command b/bin/fuzz-edit-command @@ -1,2 +1,2 @@ #!/usr/bin/env bash -file=$(cutt -f3 $HOME/dotfiles/commands | $FUZZER) && sedit "$file" +file=$(cutt -f3 $HOME/dotfiles/commands | $FUZZER) && echo "sedit $file" diff --git a/bin/fuzz-edit-command-list b/bin/fuzz-edit-command-list @@ -1,2 +1,2 @@ #!/usr/bin/env sh -exec $EDITOR $HOME/dotfiles/commands +echo $EDITOR $HOME/dotfiles/commands diff --git a/bin/fuzz-edit-file b/bin/fuzz-edit-file @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -e +file=$(rg --files | $FUZZER | xargs readlink -f) +echo $EDITOR \"$file\" diff --git a/bin/fuzz-edit-scripts b/bin/fuzz-edit-scripts @@ -2,4 +2,4 @@ # TODO: edit any script in path set -e file="$(ls -1 $HOME/bin | $FUZZER)" -$EDITOR "$HOME/bin/$file" +echo $EDITOR "$HOME/bin/$file" diff --git a/bin/fuzz-run-command b/bin/fuzz-run-command @@ -1,9 +1,19 @@ #!/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 + +function runner() { + local res + local get_cmd + local fhist + local cmd + res=$($FUZZER --select-1 --exit-0 -q ^"$@" < $HOME/dotfiles/commands) && + get_cmd=$(cutt -f3 <<<"$res") || return + fhist="$HOME/.fuzzhist" + touch "$fhist" + cmd="$($get_cmd)" + if [ -n "$cmd" ]; then + echo "$cmd" >> "$fhist" + eval $cmd + fi +} + +runner "$@" diff --git a/bin/fuzz-run-hist b/bin/fuzz-run-hist @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +touch $HOME/.fuzzhist +<$HOME/.fuzzhist uniq | tail -n 10000 > $HOME/.fuzzhist.2 +mv $HOME/.fuzzhist.2 $HOME/.fuzzhist +cmd=$(<$HOME/.fuzzhist $FUZZER --tac) && +echo $cmd diff --git a/bin/fuzz-show-fuzz-command b/bin/fuzz-show-fuzz-command @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +file=$(cutt -f3 $HOME/dotfiles/commands | $FUZZER) && dog "$file" diff --git a/bin/fuzz-show-script b/bin/fuzz-show-script @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +file="$(ls -1 "$HOME/bin" | $FUZZER)" && cat "$HOME/bin/$file" diff --git a/bin/fuzz-tag-jump b/bin/fuzz-tag-jump @@ -0,0 +1,2 @@ +#!/usr/bin/env bash +<tags sed -En '/^!/d;s,^([^\t]+).*,\1,p' | sort -u | $FUZZER