st_copyout (449B)
1 #!/bin/sh 2 3 tmpfile=$(mktemp /tmp/st-cmd-output.XXXXXX) 4 trap 'rm $tmpfile' 0 1 15 5 sed -n "w $tmpfile" 6 7 ps1="$(grep "\S" "$tmpfile" | tail -n 1 | sed 's/^s*//')" 8 9 chosen="$(grep -F "$ps1" "$tmpfile" | sed '$ d' | tac | dmenu -p "Copy which command's output?" -i -l 10 | sed 's/[^^]/[&]/g; s/\^/\\^/g')" 10 11 esp1="$(echo "$ps1" | sed 's/[^^]/[&]/g; s/\^/\\^/g')" 12 awk "/^$chosen$/{p=1;print;next} p&&/$esp1/{p=0};p" "$tmpfile" | xclip -selection clipboard