Comment 11 for bug 1854092

Revision history for this message
psl (slansky) wrote :

Another idea for pbcopy & pbpaste use, simple snippet processor that works in every application that works with clipboard. Could be useful if you have to fill forms with similar values again and again...

```
# MAIN
#pbcopy </dev/null # clear clipboard
OUT=""
while :; do
   TXT="$(pbpaste)" # read from clipbard
   if [ "$TXT" = "$OUT" ]; then
       # wait for a change
       sleep 0.1 # sleep 100ms
       continue
   fi
   OUT="$TXT"
   # define your macros/snippets
   case "$TXT" in
      "M1") OUT="MACRO1";;
      "M2") OUT="MACRO M2";;
      "IP1") OUT="fdf4:26f8:bebb:0:3973:b5eb:fe86:b000";;
      "IP2") OUT="fdf4:26f8:bebb:0:f1bf:a0f:efb:c2e2";;
      "IP3") OUT="2a00:1450:4014:80d::200e";;
      "!D") OUT="$(date '+%Y-%m-%d')";;
      "!T") OUT="$(date '+%H:%M:%S')";;
      "!!") OUT="$(date '+%Y-%m-%d %H:%M:%S')";;
      "!@") <email address hidden>";;
      # LOOP, Loop and loop, they cycle!
      "LOOP") OUT="Loop";;
      "Loop") OUT="loop";;
      "loop") OUT="LOOP";;
   esac
   if [ "$TXT" != "$OUT" ]; then
       echo "REPLACE: $TXT -> $OUT"
       echo -n "$OUT" | pbcopy # write to clipboard
   fi
done
```