Skip to content

Instantly share code, notes, and snippets.

@seamusdemora
Last active April 19, 2018 19:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seamusdemora/024caa1f4d3cdd0d8596c27051be1c74 to your computer and use it in GitHub Desktop.
Save seamusdemora/024caa1f4d3cdd0d8596c27051be1c74 to your computer and use it in GitHub Desktop.
UTF-8 Text Filter for BBEdit
#!/bin/bash
# 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
end
EOT)
# if a value is returned, convert the file to
# UTF-8 (txt) using textutil
if [ $? -eq 0 ]
then
/usr/bin/textutil -convert txt $file_to_change
else
echo "User canceled"
fi
@seamusdemora
Copy link
Author

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