Use aspell to spellcheck with Obsidian

I can’t live without spellcheck, so I wrote a quick little script to make it easier to use aspell. Aspell is a command line spellcheck program.

I know this will work with Linux and Macs. It probably will Windows as well, but I’m unsure about the setup.

First, install aspell:

Macs
$ brew install aspell

Linux
$ sudo apt install aspell
$ sudo yum install aspell

Create the script using your favorite text editor:

$ vim spchk.sh

#!/bin/bash

# set vault directory
vault=~/Dropbox/obsidian-vault/ <-- change this path to where your obsidian vault is

# search for file, set path
obsidian_file=$(find $vault -name "${*}.md" -exec echo {} \;)

# run spell check on file
aspell --dont-backup check "$obsidian_file" <-- If you want backup files remove "--don't-backup"

Set file permission:

$ chmod 750 spchk.sh

Run spellcheck:

$ ./spchk.sh note name

If aspell finds a spelling error it will come up with a menu. If it returns silently, that means there are no spelling errors.

This is a quick and dirty way to use spellcheck with Obsidian via the command line. This setup can be improved by running out of bashrc as a function, set the path to the executable, etc. Hopefully, this will help someone, or spur someone to do something better. :slight_smile:

6 Likes

This is fantastic. Thank you so much.

1 Like

At first, I was very excited about aspell and especially about its interactive mode. Soon, however, I ran into two major deal-breakers:

  1. aspell does not seem to work well with languages that use a lot of compound words. For instance, it would incorrectly flag German words such as “Detailwissen” and then only suggest incorrect variations like “Detail-wissen” and “Detail wissen”. This seemed to happen for tons and tons of words.
  2. aspell cannot handle multi-lingual notes, and many of my notes contain both English and German, often in almost equal parts.

I never considered the macOS built-in spellchecker to be particularly great, but this experience has taught me otherwise. It not only handles complex German compound words very well, it also does not flinch if you throw an eclectic mix of languages at it. :slight_smile:

Long story short, my workaround is now to use The Archive for spellchecking. Since it’s a native Mac app, the macOS spellchecker works there just fine, and even though it’s not as feature rich as Obsidian, it’s a pretty good markdown-based notes app, too. Using Keyboard Maestro, I can open my current Obsidian note with a single keystroke in The Archive.

Of course that workflow is no replacement for a proper check-as-you-type spellchecker in Obsidian, but it beats not finding a note because the word you are searching for is misspelled in that note.

For me the easiest way to spell check is this:

  • Install Typora and set it as the default editor for .md files
  • From any note you can use the option to open in the default editor, see and correct the errors.

I’ve used this system with Windows and Linux

@A_Simon’s way is actually the most elegant one. It’s only 2 clicks away (3-dots menu, “Open in default app”) and Obsidian will immediately see the changes.

Personally, I don’t use spellcheckers but lots of LaTeX and Pandoc stuff, so I use this method to open files in MarkText or Apostrophe, for instance.

1 Like

I use a hotkey for this

1 Like