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?
-
1Hi Shervin, welcome to Ask Different. Could you expand on what the vocabulary list should look like? Is it simply a list of words in a text file in your Documents folder or more sophisticated (for example, formatted and with additional information)? The former shouldn't be too difficult to implement with an Automator Service.– jaumeCommented Jun 18, 2020 at 10:37
-
Hey Jaume, thank you for your answer! Yes, it should just append and save the words into a text file so that I have an overview of them. Do you think I can use the Automator service (of macOS) for that need?– ShervinCommented Jun 18, 2020 at 13:49
-
1Yes, definitely, take a look at my answer.– jaumeCommented Jun 18, 2020 at 21:13
1 Answer
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
/Applications
).Search for "shell" and drag the "Run Shell Script" action to the right panel:
Configure it to receive selected text from the current application and add this script, modifying
~/Documents/Vocabulary.txt
to your needs (see below for a fancier script):if [ "$@" != "" ]; then echo "$@" >> ~/Documents/Vocabulary.txt fi
Save the Quick Action with a meaningful name like
Save to Vocabulary List
: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 (
~/Documents/Vocabulary.txt
).
Going fancy
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 ~/Documents/Vocabulary.html
):
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.
-
-
No, no words will be added to the standard dictionary. This will only add selected words to a text or HTML file.– jaumeCommented Jun 19, 2020 at 8:39
-
1wow, thank you so much for you excellent tutorial and your great solution. It is finally better than I imagined! I chose the name "Save to Vocabulary List by Jaume" ;)– ShervinCommented Jun 19, 2020 at 19:27
-
Wow, that's a huge compliment, thank you, I'm glad I could help!– jaumeCommented Jun 19, 2020 at 21:02