suckless/st/st-copylines
Arija A. d0a994d534
Init
Signed-off-by: Arija A. <ari@ari.lt>
2025-05-25 22:11:02 +03:00

17 lines
483 B
Bash
Executable file

#!/bin/sh
tmpfile=$(mktemp /tmp/st-cmd-output.XXXXXX)
trap 'rm "$tmpfile"' 0 1 15
sed -n "w $tmpfile"
sed -i 's/\x0//g; /^\s*$/d' "$tmpfile"
from="$(nl -w2 -s' ' <"$tmpfile" | dmenu -p 'From:' | awk '{print $1}')"
to="$(nl -w2 -s' ' <"$tmpfile" | dmenu -p 'To:' | awk '{print $1}')"
if [ "$to" -lt "$from" ]; then
notify-send "Bad range" "${from} > ${to} condinion has been met. Invalid range."
exit 1
fi
sed -n "${from},${to} p" "$tmpfile" | xclip -selection clipboard