Skip to content

Instantly share code, notes, and snippets.

@uriel1998
Last active June 28, 2024 11:33
Show Gist options
  • Save uriel1998/37b731725653def3b675705546d14f22 to your computer and use it in GitHub Desktop.
Save uriel1998/37b731725653def3b675705546d14f22 to your computer and use it in GitHub Desktop.
#!/bin/bash
# uses a complex sed string -- along with copyq and xclip -- to pull a selected string in and capitalize it.
# I use this with AutoKey.
# see https://ideatrash.net/2024/06/using-sed-to-capitalize-titles-and-a-tricky-escaping-problem.html for explanation
/usr/bin/copyq select 0
/usr/bin/copyq read 0 | sed -e "s/\b\(.\)/\u\1/g" -e "s/-\(.\)/-\u\1/g" -e 's/“/"/g' -e 's/”/"/g' -e "s/’/'/g" -e 's/—/ -- /g' -e 's/ — / -- /g' -e 's/ - / -- /g' -e 's/ – / -- /g' -e 's/ – / -- /g' -e "s/"\'"\([A-Z]\)\b/"\'"\l\1/g" -e "s/"\'"\([A-Za-z][A-Za-z]\)\b/"\'"\l\1/g" | /usr/bin/copyq write 0 -
/usr/bin/copyq select 0
/usr/bin/copyq read 0 | xclip -i
/usr/bin/copyq select 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment