Advertisement
smeech

Clipboard manipulation 2

May 1st, 2024 (edited)
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.95 KB | None | 0 0
  1. # Espanso clipboard manipulation, new version to select relevant script line using the choice extension id: parameters.
  2.  
  3.   # Bash version
  4.   - trigger: :case
  5.     label: "Modify and paste copied text"
  6.     replace: "{{output}}"
  7.     vars:
  8.       - name: clipb
  9.         type: clipboard
  10.       - name: script_choice
  11.         type: choice
  12.         params:
  13.           values:
  14.             - label: Uppercase
  15.               id: echo ""{{clipb}}"" | tr [:lower:] [:upper:]
  16.             - label: Lowercase
  17.               id: echo ""{{clipb}}"" | tr [:upper:] [:lower:]
  18.             - label: Initcase
  19.               id: awk '{for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) tolower(substr($i,2))}1' <<< "{{clipb}}"
  20.             - label: Evaluate equation
  21.               id: awk "BEGIN {print {{clipb}}}"
  22.             - label: Word count
  23.               id: echo "{{clipb}}" ; echo "{{clipb}}" | wc -w
  24.       - name: output
  25.         type: shell
  26.         params:
  27.           shell: bash
  28.           cmd: "{{script_choice}}"
  29.  
  30.   # pwsh version
  31.   - trigger: :pase
  32.     label: "Modify and paste copied text"
  33.     replace: "{{output}}"
  34.     vars:
  35.       - name: clipb
  36.         type: clipboard
  37.       - name: script_choice
  38.         type: choice
  39.         params:
  40.           values:
  41.             - label: Uppercase
  42.               id: "echo '{{clipb}}' | ForEach-Object { $_.ToUpper() }"
  43.             - label: Lowercase
  44.               id: "echo '{{clipb}}' | ForEach-Object { $_.ToLower() }"
  45.             - label: Initcase
  46.               id: "echo '{{clipb}}' | % { ($_.Split(' ') | ForEach-Object { $_.Substring(0,1).ToUpper() + $_.Substring(1).ToLower() }) -join ' ' }"
  47.             - label: Evaluate equation
  48.               id: "echo '{{clipb}}' | Invoke-Expression"
  49.             - label: Word count
  50.               id: "echo '{{clipb}}' | Measure-Object -Word | Select-Object -ExpandProperty Words"
  51.       - name: output
  52.         type: shell
  53.         params:
  54.           shell: pwsh
  55.           cmd: "{{script_choice}}"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement