From 388affce48dfaa46637ee5ab5dcc31224b1e4713 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Tue, 22 Apr 2025 13:55:13 -0400 Subject: [PATCH] AutoYADM commit: 2025-04-22 13:55:13 --- .config/helix/scripts/typst-zathura.fish | 29 +++++++++++++++++------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/.config/helix/scripts/typst-zathura.fish b/.config/helix/scripts/typst-zathura.fish index bb84312c..2b7cfcea 100755 --- a/.config/helix/scripts/typst-zathura.fish +++ b/.config/helix/scripts/typst-zathura.fish @@ -1,9 +1,22 @@ #!/usr/bin/env fish +argparse q/quiet -- $argv + function z --wraps zathura zathura "$argv[1]" &>/dev/null & end +function find_pdf + set -l root $argv[1] + set -l base $argv[2] + set -l candidate (fd --no-ignore-vcs -F -1 "$base" "$root") + if test "$candidate" != '' + z "$candidate" + else + return 1 + end +end + set -l src (path resolve $argv[1]) # echo $src # string replace @@ -16,16 +29,16 @@ else # if we're in a git repo, search from root # if we're not, search from cwd if git rev-parse --is-inside-work-tree &>/dev/null - echo in git + # echo in git set -l root (git rev-parse --show-toplevel) - echo $root + # echo $root set -l base (path basename --no-extension $src).pdf - set -l candidate (fd --no-ignore-vcs -F -1 "$base" "$root") - if test "$candidate" != '' - z "$candidate" - else - echo "$base" could not be found! - return 1 + if not find_pdf "$root" "$base" + if set -q _flag_q + return 1 + else + echo "$base couldn't be found!" + end end else echo out git