AutoYADM commit: 2025-04-22 17:45:06
This commit is contained in:
parent
b73faec60c
commit
31527457be
2 changed files with 14 additions and 12 deletions
|
@ -183,7 +183,7 @@ C-u = ["page_cursor_half_up", "align_view_center"]
|
||||||
# typst
|
# typst
|
||||||
[keys.normal.space.l.t]
|
[keys.normal.space.l.t]
|
||||||
# open pdf preview
|
# open pdf preview
|
||||||
p = ':sh ~/.config/helix/scripts/typst-zathura.fish %{buffer_name}'
|
p = ':sh ~/.config/helix/scripts/typst-zathura.fish -k %{buffer_name}'
|
||||||
|
|
||||||
# git stuff
|
# git stuff
|
||||||
[keys.normal.space.g]
|
[keys.normal.space.g]
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/env fish
|
#!/usr/bin/env fish
|
||||||
argparse q/quiet k/kill-on-exit h/help -- $argv
|
argparse q/quiet k/kill-on-exit h/help -- $argv
|
||||||
|
|
||||||
if test (count $argv) -e 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."
|
||||||
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 typst-zathura [opts] %{buffer_name}'
|
||||||
|
@ -44,22 +44,23 @@ function find_parent_process -a target
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
set -q _flag_k; and set parent_pid (find_parent_process hx)
|
if set -q _flag_k
|
||||||
if set -q _flag_k; and test -z "$parent_pid"
|
set kill_parent
|
||||||
qecho "Couldn't find parent hx process!"
|
echo "kill flag set"
|
||||||
return $ret
|
set parent_pid (find_parent_process hx)
|
||||||
|
if test -z "$parent_pid"
|
||||||
|
qecho "Couldn't find parent hx process!"
|
||||||
|
return $ret
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# opens zathura, watching for helix closing
|
# opens zathura, watching for helix closing
|
||||||
function zopen --wraps zathura
|
function zopen --wraps zathura
|
||||||
if set -q _flag_k
|
if set -q kill_parent
|
||||||
begin
|
begin
|
||||||
zathura "$argv[1]" &>/dev/null &
|
zathura "$argv[1]" &>/dev/null &
|
||||||
set zathura_pid $last_pid
|
set zathura_pid $last_pid
|
||||||
notify-send zathura "$zathura_pid"
|
|
||||||
notify-send hx $parent_pid
|
|
||||||
waitpid "$parent_pid"
|
waitpid "$parent_pid"
|
||||||
notify-send "helix killed"
|
|
||||||
kill $zathura_pid
|
kill $zathura_pid
|
||||||
end &
|
end &
|
||||||
else
|
else
|
||||||
|
@ -71,7 +72,7 @@ function find_pdf
|
||||||
set -l root $argv[1]
|
set -l root $argv[1]
|
||||||
set -l base $argv[2]
|
set -l base $argv[2]
|
||||||
set -l candidate (fd --no-ignore-vcs -F -1 "$base" "$root")
|
set -l candidate (fd --no-ignore-vcs -F -1 "$base" "$root")
|
||||||
if test "$candidate" != ''
|
if test -n "$candidate"
|
||||||
zopen "$candidate"
|
zopen "$candidate"
|
||||||
else
|
else
|
||||||
return 1
|
return 1
|
||||||
|
@ -85,6 +86,7 @@ if not string match -q '*.typ' $src
|
||||||
end
|
end
|
||||||
set -l targ (string replace '.typ' '.pdf' $src)
|
set -l targ (string replace '.typ' '.pdf' $src)
|
||||||
set -l base (path basename --no-extension $src).pdf
|
set -l base (path basename --no-extension $src).pdf
|
||||||
|
|
||||||
if test -f "$targ" -a '' != ''
|
if test -f "$targ" -a '' != ''
|
||||||
# zathura "$targ" &>/dev/null &
|
# zathura "$targ" &>/dev/null &
|
||||||
zopen "$targ"
|
zopen "$targ"
|
||||||
|
@ -104,7 +106,7 @@ else
|
||||||
if set -q _flag_q
|
if set -q _flag_q
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
echo "$base couldn't be found!"
|
echo "$base couldn't be found at root $root!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue