I search for a way to add unknown words in a personal dictionary or vocabulary list only by right-clicking the word and choosing the add option (in macOS). It would be very helpful for me to add the words directly to a vocabulary list, without breaking my workflow. I already found an addon for chrome which resolves my problem (you can see it on the attached screenshot). But I need a similar (overarching) solution that works with various apps (like PDF reader (Preview in macOS), other web browsers (safari)..). If there isn't any app for this "issue", would it be difficult for somebody without specific Swift (or macOS development) knowledge but expertise in other languages to write a small (background) APP in swift for helping me out?
You can create an Automator Quick Action that takes the selected word as input and saves it to a predefined document. The Quick Action can then be configured with a keyboard shortcut of your choosing.
Setting it up
Launch Automator (located in
Configure it to receive selected text from the current application and add this script, modifying
~/Documents/Vocabulary.txtto your needs (see below for a fancier script):
if [ "$@" != "" ]; then echo "$@" >> ~/Documents/Vocabulary.txt fi
Open System Preferences>Keyboard>Shortcuts, select Services from the list on the left panel, enable the Quick Action and set a "complex" keyboard shortcut, for example ControlShiftCommandV, to reduce the change of a conflict with an existing one:
Open an app, select some text, press ControlShiftCommandV and the text will be added to the file configured in the Quick Action (
You can easily extend the script's functionality (basic scripting knowledge required). For example, to add a timestamp and a link to the Dictionary app, use this script instead (note that the vocabulary list is now saved to the HTML file
if [ "$@" != "" ]; then timestamp="$(date +%Y-%m-%d' '%H:%M:%S)" dictlink="dict://$(echo $@ | sed 's/ /%20/')" ahref="<A HREF=\"$dictlink\">$@</A>" echo "$timestamp - $ahref</br>" >> ~/Documents/Vocabulary.html fi
When opened in Safari, the vocabulary file looks like this:
and you can click the word to look it up in the Dictionary app.