Skip to content

Instantly share code, notes, and snippets.

Last active April 19, 2018 19:48
What would you like to do?
UTF-8 Text Filter for BBEdit
# launch AppleScript to retrieve filename of file to
# be converted and store the result in `file_to_change`
file_to_change=$(/usr/bin/osascript << EOT
tell app "BBEdit"
set filePath1 to file of document 1
set filePath2 to POSIX path of filePath1
# if a value is returned, convert the file to
# UTF-8 (txt) using textutil
if [ $? -eq 0 ]
/usr/bin/textutil -convert txt $file_to_change
echo "User canceled"
Copy link

seamusdemora commented Apr 19, 2018

A simple UTF-8 converter for BBEdit. Place the file in the usual location for these things, and make it executable.

And thanks to sakra for the enlightenment on how to run an AppleScript inside bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment