Advertisement
smeech

Clipboard manipulation

Mar 18th, 2024 (edited)
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.43 KB | Software | 0 0
  1. # Inspired by Andreas Thuresson here is an Espanso expansion that takes selected/highlighted text, triggered by :case, and offers a few manipulation options.
  2.  
  3.   - trigger: :case
  4.     label: Modify and paste copied text
  5.     replace: '{{output}}'
  6.     vars:
  7.       - name: clipb
  8.         type: clipboard
  9.       - name: script_choice
  10.         type: choice
  11.         params:
  12.           values:
  13.             - label: Uppercase
  14.               id: echo ""{{clipb}}"" | tr [:lower:] [:upper:]
  15.             - label: Lowercase
  16.               id: echo ""{{clipb}}"" | tr [:upper:] [:lower:]
  17.             - label: Initcase
  18.               id: >-
  19.                 awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1))
  20.                 tolower(substr($i,2))}1' <<< "{{clipb}}"
  21.             - label: Evaluate equation
  22.               id: awk "BEGIN {print {{clipb}}}"
  23.             - label: Word count
  24.               id: echo "{{clipb}}" ; echo "{{clipb}}" | wc -w
  25.             - label: Underline
  26.               id: |
  27.                input={{clipb}}
  28.                 output=""
  29.                 underline_char=$'\u0332'
  30.                 for ((i=0; i<${#input}; i++)); do
  31.                   output+="${input:$i:1}$underline_char"
  32.                 done
  33.                 echo "$output"
  34.             - label: Email
  35.               id: thunderbird -compose "to={{clipb}}"
  36.       - name: output
  37.         type: shell
  38.         params:
  39.           shell: bash
  40.           cmd: '{{script_choice}}'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement