#!/usr/bin/env fish set -l src (path resolve $argv[1]) # echo $src # string replace set -l targ (string replace --filter '.typ' '.pdf' $src) if test -f "$targ" -a '' != '' zathura "$targ" &>/dev/null & else # no such file in current dir, time to search! # 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 set -l root (git rev-parse --show-toplevel) echo $root set -l base (path basename --no-extension) set -l base $base.pdf echo $base else echo out git set -l root (pwd) end end