From 526770c9fa3d2d88e3a2c75d989262e662fa2a66 Mon Sep 17 00:00:00 2001 From: Daniel Fichtinger Date: Fri, 18 Jul 2025 18:20:13 -0400 Subject: [PATCH] AutoYADM commit: 2025-07-18 18:20:13 --- .config/kak/autoload/local-kakrc.kak | 28 ++++++++++++++-------------- .config/kak/local_kakrc_trusted.txt | 1 - 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/.config/kak/autoload/local-kakrc.kak b/.config/kak/autoload/local-kakrc.kak index 4298576a..61ca74c8 100644 --- a/.config/kak/autoload/local-kakrc.kak +++ b/.config/kak/autoload/local-kakrc.kak @@ -15,9 +15,7 @@ provide-module local-kakrc %— # first we check if the .kakrc exists evaluate-commands %sh{ if [ -f .kakrc ]; then - notify-send "Found it!" - # check if it's a trusted dir - if grep -q "$PWD" "$kak_opt_local_kakrc_trusted"; then + if grep -qFx "$PWD" "$kak_opt_local_kakrc_trusted"; then echo "source .kakrc" else 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 %{ - nop %sh{ + evaluate-commands %sh{ if [ "$#" -eq 0 ]; then arg="$PWD" else arg="$(realpath "$1")" fi 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 temp="$(mktemp)" touch "$temp" - if grep -vxF "$arg" "$kak_opt_local_kakrc_trusted" >"$temp"; then - mv -f "$temp" "$kak_opt_local_kakrc_trusted" + # check if path is in file + 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 - 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 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 %{ fd -td --exclude '.git' --base-directory "$PWD" . } # syntax highlighting - hook global BufCreate (.*/)?\.kakrc %{ + hook global BufCreate (.*/)?(\.kakrc) %{ set-option buffer filetype kak } - # load proj. config - define-command root-load-kakrc %{ - try %{ source %exp{%opt{root_path}/.kakrc} } - } — diff --git a/.config/kak/local_kakrc_trusted.txt b/.config/kak/local_kakrc_trusted.txt index 0b671ad1..9de02730 100644 --- a/.config/kak/local_kakrc_trusted.txt +++ b/.config/kak/local_kakrc_trusted.txt @@ -1,2 +1 @@ -/home/fic/Documents /tmp/kak-trusted