AutoYADM commit: 2025-07-18 18:20:13

This commit is contained in:
Daniel Fichtinger 2025-07-18 18:20:13 -04:00
parent 360560fd2b
commit 526770c9fa
2 changed files with 14 additions and 15 deletions

View file

@ -15,9 +15,7 @@ provide-module local-kakrc %—
# first we check if the .kakrc exists # first we check if the .kakrc exists
evaluate-commands %sh{ evaluate-commands %sh{
if [ -f .kakrc ]; then if [ -f .kakrc ]; then
notify-send "Found it!" if grep -qFx "$PWD" "$kak_opt_local_kakrc_trusted"; then
# check if it's a trusted dir
if grep -q "$PWD" "$kak_opt_local_kakrc_trusted"; then
echo "source .kakrc" echo "source .kakrc"
else else
echo "info -title 'local-kakrc' 'Local .kakrc found, but directory is untrusted.'" echo "info -title 'local-kakrc' 'Local .kakrc found, but directory is untrusted.'"
@ -27,14 +25,15 @@ provide-module local-kakrc %—
} }
define-command -params 0..1 local-kakrc-add-trusted %{ define-command -params 0..1 local-kakrc-add-trusted %{
nop %sh{ evaluate-commands %sh{
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
arg="$PWD" arg="$PWD"
else else
arg="$(realpath "$1")" arg="$(realpath "$1")"
fi fi
echo "local-kakrc-ensure-file">"$kak_command_fifo" echo "local-kakrc-ensure-file">"$kak_command_fifo"
printf '%s\n' "$arg">"$kak_opt_local_kakrc_trusted" printf 'info -title "local-kakrc" "Adding %s to trusted"' "$arg"
printf '%s\n' "$arg">>"$kak_opt_local_kakrc_trusted"
} }
} }
@ -51,26 +50,27 @@ provide-module local-kakrc %—
fi fi
temp="$(mktemp)" temp="$(mktemp)"
touch "$temp" touch "$temp"
if grep -vxF "$arg" "$kak_opt_local_kakrc_trusted" >"$temp"; then # check if path is in file
mv -f "$temp" "$kak_opt_local_kakrc_trusted" if grep -qFx "$arg" "$kak_opt_local_kakrc_trusted"; then
# perform removal
grep -vxF "$arg" "$kak_opt_local_kakrc_trusted" >"$temp"
mv -f "$temp" "$kak_opt_local_kakrc_trusted"
else else
notify-send "this runs" echo "info -title 'local-kakrc' 'No such trusted directory!'"
echo "info -title 'local-kakrc' 'No such trusted directory!'"
rm "$temp" 2>/dev/null rm "$temp" 2>/dev/null
fi fi
} }
} }
complete-command local-kakrc-rm-trusted shell-script-candidates %{
cat "$kak_opt_local_kakrc_trusted"
}
complete-command local-kakrc-add-trusted shell-script-candidates %{ complete-command local-kakrc-add-trusted shell-script-candidates %{
fd -td --exclude '.git' --base-directory "$PWD" . fd -td --exclude '.git' --base-directory "$PWD" .
} }
# syntax highlighting # syntax highlighting
hook global BufCreate (.*/)?\.kakrc %{ hook global BufCreate (.*/)?(\.kakrc) %{
set-option buffer filetype kak set-option buffer filetype kak
} }
# load proj. config
define-command root-load-kakrc %{
try %{ source %exp{%opt{root_path}/.kakrc} }
}

View file

@ -1,2 +1 @@
/home/fic/Documents
/tmp/kak-trusted /tmp/kak-trusted