Skip to content

Instantly share code, notes, and snippets.

@unforswearing
Last active March 11, 2016 03:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unforswearing/42d67c1552aee194efb9 to your computer and use it in GitHub Desktop.
Save unforswearing/42d67c1552aee194efb9 to your computer and use it in GitHub Desktop.
an automator script to wrap punctuation around text
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