Howdy folks, I've been trying to learn some how to work with shell scripts lately, so I've been making great use of Homebrew packages to make some basic macros.
My latest one is a simple spell check using Aspell (a Homebrew package). It selects the word to the left of the cursor, runs it through Aspell's cli to verify correct spelling or produce a list (comma delimited) of possible corrections.
If the word is spelled correctly a notification is displayed indicating that. If not, Aspell returns a list of possible matches. Using some simple RegEx, I remove Aspell's version info and then change the comma delimiters to new line feed delimiters and then display the tidied up list in a prompt from list action. This allows you to choose the correct word. Once you select a word, it pastes over the incorrectly spelled word and moves to the end of the line of text.
Attached is a screen recording of it in action (note that the display in a window is only because QuickTime doesn’t grab system notifications, but the actual macro has a system style notification for correctly spelled words).
While the macro works quite well for me (and why I posted it here, and not in the Questions and Suggestions category), I'm still interested in everybody's thoughts and ideas if this macro can be improved. Thanks in advance, and if this macro proves useful to anybody else then enjoy!
-Chris
NOTE: This macro has special requirements to run
This macro makes use of the following KM version 10 action(s):
Position next engine window
If you are running a previous version of KM, simply disable or remove said action(s).
This macro requires Homebrew to be installed. Click the link for more info.
This macro requires Aspell (a Homebrew package) to be installed. Click the link for more info.
Also see this page for a list of language codes and also see this page for a list of Aspell command options.
This macro requires the end-user to set a ENV_PATH
variable (or specify the path in the shell script). Click the link for more info.
CURRENT VERSION: 1.2.1 (Wednesday, May 18, 2022)
v1.2.1: Wednesday, May 18, 2022
Added instructions about changing the triggers.
v1.2.0: Wednesday, February 02, 2022
If you use this in conjunction with Typinator, the spell check prompt list will be positioned next to the Create new Typinator Item window if it is open.
v1.1.2: Friday, January 28, 2022
Added a step to delete past clipboard so as not to lose whatever was previously on the clipboard
v1.1.1: Thursday, January 27, 2022
I added KM10's Set Next Engine Window action to ensure the list appears on the front screen.
v1.1: Sunday, January 23, 2022
I added a few extra actions to allow for different languages based on the %TriggerValue%
token. There are obviously many different ways to do this, such as a prompt allowing you to select a language but I only speak two languages so my needs are few . See the comments in the macro for a more detailed explanation of spell checking other languages.
v1.0: Friday, January 21, 2022
Initial macro
51)Spell check.kmmacros (58 KB)