AutoYADM commit: 2025-04-22 13:55:13
This commit is contained in:
parent
df0e3e4a89
commit
388affce48
1 changed files with 21 additions and 8 deletions
|
@ -1,9 +1,22 @@
|
||||||
#!/usr/bin/env fish
|
#!/usr/bin/env fish
|
||||||
|
|
||||||
|
argparse q/quiet -- $argv
|
||||||
|
|
||||||
function z --wraps zathura
|
function z --wraps zathura
|
||||||
zathura "$argv[1]" &>/dev/null &
|
zathura "$argv[1]" &>/dev/null &
|
||||||
end
|
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])
|
set -l src (path resolve $argv[1])
|
||||||
# echo $src
|
# echo $src
|
||||||
# string replace
|
# string replace
|
||||||
|
@ -16,16 +29,16 @@ else
|
||||||
# if we're in a git repo, search from root
|
# if we're in a git repo, search from root
|
||||||
# if we're not, search from cwd
|
# if we're not, search from cwd
|
||||||
if git rev-parse --is-inside-work-tree &>/dev/null
|
if git rev-parse --is-inside-work-tree &>/dev/null
|
||||||
echo in git
|
# echo in git
|
||||||
set -l root (git rev-parse --show-toplevel)
|
set -l root (git rev-parse --show-toplevel)
|
||||||
echo $root
|
# echo $root
|
||||||
set -l base (path basename --no-extension $src).pdf
|
set -l base (path basename --no-extension $src).pdf
|
||||||
set -l candidate (fd --no-ignore-vcs -F -1 "$base" "$root")
|
if not find_pdf "$root" "$base"
|
||||||
if test "$candidate" != ''
|
if set -q _flag_q
|
||||||
z "$candidate"
|
return 1
|
||||||
else
|
else
|
||||||
echo "$base" could not be found!
|
echo "$base couldn't be found!"
|
||||||
return 1
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
echo out git
|
echo out git
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue