Last active
April 19, 2018 19:48
-
-
Save seamusdemora/024caa1f4d3cdd0d8596c27051be1c74 to your computer and use it in GitHub Desktop.
UTF-8 Text Filter for BBEdit
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
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.