nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

commit dff36bffbac1b0be5ab52ed15cb28387fccb7cf5
parent b2bf88f21ae378487c630034e79d45c23af7f33c
Author: mtmn <miro@haravara.org>
Date:   Sat,  9 May 2026 02:03:49 +0200

bin: add `wrd` www fuzzy helper

Diffstat:
Mmodules/mixins/dotfiles/bin/speedread | 13+++++++++----
Amodules/mixins/dotfiles/bin/wrd | 23+++++++++++++++++++++++
2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/modules/mixins/dotfiles/bin/speedread b/modules/mixins/dotfiles/bin/speedread @@ -43,10 +43,13 @@ use Term::ANSIColor; use POSIX qw(ceil floor); use Time::HiRes qw(time sleep gettimeofday tv_interval); +my $offset = 0; + use Getopt::Long; GetOptions("wpm|w=i" => \$wpm, "resume|r=i" => \$resume, - "multiword|m" => \$multiword); + "multiword|m" => \$multiword, + "offset|o=i" => \$offset); my $wordtime = 0.9; # relative to wpm my $lentime = 0.04; # * sqrt(length $word), relative to wpm @@ -56,8 +59,8 @@ my $multitime = 1.2; # relative to wpm my $firsttime = 0.2; # [s] my $ORPloc = 0.35; my $ORPmax = 0.2; -my $ORPvisualpos = 20; -my $cursorpos = 64; +my $ORPvisualpos = 20 + $offset; +my $cursorpos = 64 + $offset; my $paused = 0; my $current_word; my $current_orp; @@ -108,6 +111,8 @@ sub show_word { my $pivotch = substr($word, $i, 1); $pivotch = "ยท" if $pivotch eq ' '; + my $rpad = $cursorpos - ($ORPvisualpos - $i) - length($word); + $rpad = 0 if $rpad < 0; print("\r\033[K" . " " x ($ORPvisualpos - $i) . color("bold") @@ -118,7 +123,7 @@ sub show_word { . color("bold") . substr($word, $i+1) . color("reset") - . " " x ($cursorpos - (($ORPvisualpos - $i) + length($word))) + . " " x $rpad . "$wpm wpm" . ($paused ? " ".color("yellow")."PAUSED".color("reset") : "")); } diff --git a/modules/mixins/dotfiles/bin/wrd b/modules/mixins/dotfiles/bin/wrd @@ -0,0 +1,23 @@ +#!/bin/sh +tmp=$(mktemp) +trap 'rm -f "$tmp"' EXIT INT TERM + +while true; do + picked=$(fd -e html -e md . "$HOME/misc/www" --exec stat -c '%Y %n' | sort -rn | cut -d' ' -f2- | fzf --reverse --delimiter=/ --with-nth=-1 \ + --preview='case {} in + *.html) offpunk --dump {} 2>/dev/null || bat {};; + *.md) lowdown -Tterm {} 2>/dev/null || bat {};; + esac') + + [ -z "$picked" ] && break + + case "$picked" in + *.html) offpunk "$picked" ;; + *.md) + lowdown -Tterm "$picked" | + awk -v w="$(tput cols)" 'BEGIN{p=sprintf("%*s",w>80?(w-80)/2:0,"")} {print p $0}' \ + >"$tmp" + tmux display-popup -E -w 100% -h 100% "moor -no-linenumbers -no-statusbar '$tmp'" + ;; + esac +done