diff --git a/.config/kak/scripts/kakfilter.sh b/.config/kak/scripts/kakfilter.sh index f5b45b77..80ff6f2c 100755 --- a/.config/kak/scripts/kakfilter.sh +++ b/.config/kak/scripts/kakfilter.sh @@ -12,6 +12,7 @@ while getopts "f:" opt; do echo "accepts file over stdin or as argument" echo "applies and prints buffer content to stdout" echo "kakrc is not loaded" + ;; \?) echo "Invalid option" exit 1 @@ -26,8 +27,11 @@ if [ -z "$filter" ]; then exit 1 fi +# create temp files tempdir="$(mktemp -d kakpipe-XXXXXX)" fifo="${tempdir}/fifo" +# prioritize arg if it exists +# use stdin otherwise if [ -z "$1" ]; then input="$(mktemp -p ${tempdir} input.XXXXXX)" cat >"$input" @@ -35,7 +39,11 @@ else input="$1" fi -kak -n -e "exec ; execute-keys \"$filter\"; execute-keys ; write $fifo; quit!" "$input" +# run kak as a filter +# write buffer to fifo before quitting +# cmd="$(printf 'exec ; execute-keys "%s"')" +kak -n -e "exec ; execute-keys %{ $filter } ; execute-keys ; write $fifo; quit!" "$input" +# print kak output to stdout cat "$fifo" # cleanup rm -r "$tempdir" diff --git a/.config/kak/scripts/kakpipe-11nWu0/input.eXucbL b/.config/kak/scripts/kakpipe-11nWu0/input.eXucbL new file mode 100644 index 00000000..ce013625 --- /dev/null +++ b/.config/kak/scripts/kakpipe-11nWu0/input.eXucbL @@ -0,0 +1 @@ +hello