Another copy of my dotfiles. Because I don't completely trust GitHub.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

14 lines
738 B

  1. #!/bin/sh
  2. # Using external pipe with st, give a dmenu prompt of recent commands,
  3. # allowing the user to copy the output of one.
  4. # xclip required for this script.
  5. # By Jaywalker and Luke
  6. tmpfile=$(mktemp $XDG_RUNTIME_DIR/st-cmd-output.XXXXXX)
  7. trap 'rm "$tmpfile"' 0 1 15
  8. sed -n "w $tmpfile"
  9. sed -i 's/\x0//g' "$tmpfile"
  10. #ps1="$(grep "\S" "$tmpfile" | tail -n 1 | sed 's/^\s*//' | cut -d' ' -f1)"
  11. ps1="λ"
  12. chosen="$(grep -F "$ps1" "$tmpfile" | sed '$ d' | tac | grep -E -v "λ $"| dmenu -w "$WINDOWID" -p "Copy which command's output?" -i -l 10 | sed 's/[^^]/[&]/g; s/\^/\\^/g')"
  13. eps1="$(echo "$ps1" | sed 's/[^^]/[&]/g; s/\^/\\^/g')"
  14. awk "/^$chosen$/{p=1;print;next} p&&/$eps1/{p=0};p" "$tmpfile" | tail -n +2 | xclip -selection clipboard