AutoYADM commit: 2025-07-07 13:48:23

This commit is contained in:
Daniel Fichtinger 2025-07-07 13:48:23 -04:00
parent c9bd35b3c2
commit a08f423e91
2 changed files with 41 additions and 25 deletions

View file

@ -0,0 +1,41 @@
#!/bin/sh
# check for filter string
while getopts "f:" opt; do
case "$opt" in
f)
filter="$OPTARG"
;;
h)
echo "kakfilter -f <keys> [<file>]"
echo "like kak -f, but supports commands"
echo "accepts file over stdin or as argument"
echo "applies <percent><keys> and prints buffer content to stdout"
echo "kakrc is not loaded"
\?)
echo "Invalid option"
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ -z "$filter" ]; then
echo "No filter!"
exit 1
fi
tempdir="$(mktemp -d kakpipe-XXXXXX)"
fifo="${tempdir}/fifo"
if [ -z "$1" ]; then
input="$(mktemp -p ${tempdir} input.XXXXXX)"
cat >"$input"
else
input="$1"
fi
kak -n -e "exec <percent>; execute-keys \"$filter\"; execute-keys <esc>; write $fifo; quit!" "$input"
cat "$fifo"
# cleanup
rm -r "$tempdir"

View file

@ -1,25 +0,0 @@
#!/bin/sh
# check for filter string
while getopts "f:" opt; do
case "$opt" in
f)
filter="$OPTARG"
;;
\?)
echo "Invalid option"
exit 1
;;
esac
done
if [ -z "$filter" ]; then
echo "No filter!"
exit 1
fi
tempdir="$(mktemp -d kakpipe-XXXXXX)"
fifo="${tempdir}/fifo"
# cleanup
rm -r "$tempdir"