Last active
March 11, 2016 03:39
-
-
Save unforswearing/42d67c1552aee194efb9 to your computer and use it in GitHub Desktop.
an automator script to wrap punctuation around text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
which_wrap() { | |
# this script is much faster than the applescript version, but does not properly handle cancellation | |
osascript <<EOF | |
try | |
set bloog to (choose from list {"double-quote \"\"", "single-quote ''", "parenthesis ()", "curly-brace {}", "brace []", "angled-bracket <>"} with title "Select an Item" OK button name "Wrap" default items {"double-quote"} with empty selection allowed) | |
return bloog | |
if bloog is false then | |
error number -128 | |
end if | |
end try | |
EOF | |
} | |
which_wrap=$(which_wrap | sed 's/[[:punct:]]. *$/ /g;s/[[:space:]]//g') | |
case "$which_wrap" in | |
double-quote) sed 's/^/\"/;s/$/\"/';; | |
single-quote) sed "s/^/\'/;s/$/\'/";; | |
parenthesis) sed 's/^/\(/;s/$/\)/';; | |
curly-brace) sed 's/^/\{/;s/$/\}/';; | |
brace) sed 's/^/\[/;s/$/\]/';; | |
angled-bracket) sed 's/^/\</;s/$/\>/';; | |
"false") exit 1;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment