AutoYADM commit: 2025-04-22 18:30:06

This commit is contained in:
Daniel Fichtinger 2025-04-22 18:30:06 -04:00
parent 7cfc5f8797
commit ad49367f90
2 changed files with 25 additions and 11 deletions

View file

@ -184,11 +184,8 @@ C-u = ["page_cursor_half_up", "align_view_center"]
# language specific commands # language specific commands
[keys.normal.space.l] [keys.normal.space.l]
# open pdf preview for typst
# typst p = ':sh ~/.config/helix/scripts/hx-typ-zathura.fish -k %{buffer_name}'
[keys.normal.space.l.t]
# open pdf preview
p = ':sh ~/.config/helix/scripts/typst-zathura.fish -k %{buffer_name}'
# git stuff # git stuff
[keys.normal.space.g] [keys.normal.space.g]

View file

@ -1,14 +1,30 @@
#!/usr/bin/env fish #!/usr/bin/env fish
# hx-typ-zathura: easily preview your typst documents from Helix!
# This script will automatically find a pdf that matches your
# current Typst document and attempt to open it with Zathura.
# Optionally, it will quit Zathura when you close Helix.
# Run this script with --help for usage info!
# Author: Daniel Fichtinger <daniel@ficd.ca
# License: MIT
argparse q/quiet k/kill-on-exit h/help -- $argv argparse q/quiet k/kill-on-exit h/help -- $argv
if test (count $argv) -eq 0; or set -q _flag_h if test (count $argv) -eq 0; or set -q _flag_h
echo "Helper script for opening Typst files from Helix in Zathura." echo "Helper script for opening Typst files from Helix in Zathura."\n
echo "Usage: (bind the following to a key)" echo "Usage: (bind the following to a key)"
echo ':sh typst-zathura [opts] %{buffer_name}' echo ':sh hx-typ-zathura.fish [opts] %{buffer_name}'\n
echo 'Example for config.toml:'
echo '[keys.normal.space.t]'
echo 'p = \':sh /path/to/hx-typ-zathura.fish -k %\{buffer_name\}\''\n
echo "Options:" echo "Options:"
echo "-q/--quiet: Don't `echo` on caught errors, return 1 instead." echo "-q/--quiet: Don't \`echo\` on caught errors, return 1 instead."
echo "-k/--kill-on-exit: Kill Zathura when parent Helix exits." echo "-k/--kill-on-exit: Kill Zathura when parent Helix process exits."
echo "-h/--help: print this screen" echo "-h/--help: print this screen"\n
echo 'Author: Daniel Fichtinger <daniel@ficd.ca>'
echo 'License: MIT'
return 0
end end
# only return status 1 if -q not set # only return status 1 if -q not set
@ -79,9 +95,10 @@ function zopen --wraps zathura
# user didn't ask for watch, so open normally # user didn't ask for watch, so open normally
zathura "$argv[1]" &>/dev/null & zathura "$argv[1]" &>/dev/null &
end end
true
end end
# try to find the target pdf file # try to find the target pdf file searching from root
function find_pdf function find_pdf
set -l root $argv[1] set -l root $argv[1]
set -l base $argv[2] set -l base $argv[2]