├── .editorconfig ├── .gitignore ├── funding.yml ├── license ├── man └── learn.1 ├── osx-learn.sh ├── package.json └── readme.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.log 3 | -------------------------------------------------------------------------------- /funding.yml: -------------------------------------------------------------------------------- 1 | github: wooorm 2 | -------------------------------------------------------------------------------- /license: -------------------------------------------------------------------------------- 1 | (The MIT License) 2 | 3 | Copyright (c) 2015 Titus Wormer 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /man/learn.1: -------------------------------------------------------------------------------- 1 | .TH "learn" "1" "March 2018" "1.1.2" "" 2 | 3 | .SH "NAME" 4 | \fBlearn\fR - Add words to the OS X Spell Check dictionary 5 | 6 | .SH "SYNOPSIS" 7 | .P 8 | \fBlearn\fR \[lB]\fBoptions\fR\[rB] <\fIword\fR> \[lB]\fBlanguage\fR\[rB] 9 | 10 | .SH "DESCRIPTION" 11 | .P 12 | \fBlearn\fR(1) adds words to OS X\(cqs valid words list, as in, remove warnings 13 | about words like \(ganpm\(ga. 14 | 15 | If a language is specified, the language designator (ISO 639-1 or ISO 639-2) 16 | must be lower-case, e.g., \(ganl\(ga. When a region designator (ISO 3166-1) is 17 | added, it must be all-caps and preceded by an underscore, e.g., \(gaen_GB\(ga. 18 | 19 | .SH "EXAMPLE" 20 | .RS 2 21 | .nf 22 | \(Do learn npm 23 | .fi 24 | .nf 25 | \(Do learn stringification en_GB 26 | .fi 27 | .nf 28 | \(Do learn --print 29 | npm 30 | .fi 31 | .nf 32 | \(Do learn --print en_GB 33 | stringification 34 | .fi 35 | .RE 36 | 37 | .SH "OPTIONS" 38 | 39 | .SS "-v, --version" 40 | .P 41 | output version 42 | 43 | .SS "-h, --help" 44 | .P 45 | output usage information 46 | 47 | .SS "-p, --print" 48 | .P 49 | output dictionary 50 | 51 | .SH "NOTE" 52 | .P 53 | Ensure the language is enabled in \(gaSystem Preferences\(ga > \(gaKeyboard\(ga 54 | > \(gaText\(ga > \(gaSpelling\(ga > \(gaSet Up...\(ga. 55 | 56 | .P 57 | When adding a word to a language which has region designators (such as English, 58 | which has British and more), \fBYOU MUST SPECIFY THE REGION TOO\fR. 59 | In the case of British, specifying \(gaen\(ga will not work, but \(gaen_GB\(ga 60 | will. 61 | 62 | .SH "BUGS" 63 | .P 64 | <\fIhttps://github.com/wooorm/osx-learn/issues\fR> 65 | 66 | .SH "AUTHOR" 67 | .P 68 | Written by Titus Wormer <\fItituswormer@gmail.com\fR> 69 | 70 | .SH "LICENSE" 71 | .P 72 | MIT \(co Titus Wormer 73 | -------------------------------------------------------------------------------- /osx-learn.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Usage. 5 | # 6 | 7 | usage () { 8 | cat << EOF 9 | 10 | Usage: learn [options] [language] 11 | 12 | Options: 13 | 14 | -h, --help output usage information 15 | -p, --print output dictionary (default LocalDictionary) 16 | -v, --version output version 17 | 18 | Examples: 19 | 20 | $ learn npm 21 | $ learn stringification en_GB 22 | $ learn --print 23 | npm 24 | $ learn --print en_GB 25 | stringification 26 | 27 | See also: man 1 learn 28 | EOF 29 | } 30 | 31 | # 32 | # Version. 33 | # 34 | 35 | version () { 36 | echo "1.1.2" 37 | } 38 | 39 | # 40 | # Print. 41 | # 42 | 43 | print () { 44 | readonly lang=${1-"LocalDictionary"} 45 | 46 | database=~/Library/Spelling/$lang 47 | 48 | cat "$database" 49 | } 50 | 51 | # 52 | # Options. 53 | # 54 | 55 | case $1 in 56 | "") usage; exit 1 ;; 57 | -h|--help) usage; exit ;; 58 | -p|--print) print $2; exit ;; 59 | -v|--version) version; exit ;; 60 | *) readonly replace=$1 ; readonly lang=${2-"LocalDictionary"} ;; 61 | esac 62 | 63 | # 64 | # Find list. 65 | # 66 | 67 | database=~/Library/Spelling/$lang 68 | 69 | touch "$database" 70 | 71 | echo "$1" >> $database 72 | 73 | data=$(cat $database | sort | uniq) 74 | 75 | echo "$data" > $database 76 | 77 | # 78 | # Restart AppleSpell. 79 | # 80 | 81 | launchctl stop com.apple.applespell 82 | launchctl start com.apple.applespell 83 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "osx-learn", 3 | "version": "1.1.2", 4 | "description": "Add words to the OS X Spell Check dictionary", 5 | "license": "MIT", 6 | "keywords": [ 7 | "cli", 8 | "bin", 9 | "mac", 10 | "osx", 11 | "learn", 12 | "spelling", 13 | "corrent" 14 | ], 15 | "repository": "wooorm/osx-learn", 16 | "author": "Titus Wormer (https://wooorm.com)", 17 | "contributors": [ 18 | "Titus Wormer (https://wooorm.com)", 19 | "Richard Littauer " 20 | ], 21 | "files": [ 22 | "osx-learn.sh", 23 | "man" 24 | ], 25 | "bin": { 26 | "learn": "osx-learn.sh" 27 | }, 28 | "directories": { 29 | "man": "./man" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # osx-learn 2 | 3 | ![`bin/sh`][bash] 4 | 5 | > Add words to OS X’s valid words list, as in, remove warnings about words 6 | > like `npm`. 7 | 8 | Tested on OS X 10.10 (Yosemite), 10.13 (High Sierra), 10.14 (Mojave), might 9 | work earlier. 10 | 11 | If a language is specified, the language designator (ISO 639-1 or ISO 639-2) 12 | must be lower-case, e.g., `nl`. 13 | When a region designator (ISO 3166-1) is added, it must be all-caps and 14 | preceded by an underscore, e.g., `en_GB`. 15 | 16 | Ensure the language is enabled in `System Preferences` > `Keyboard` > 17 | `Text` > `Spelling` > `Set Up...`. 18 | 19 | When adding a word to a language which has region designators (such as English, 20 | which has British and more), **YOU MUST SPECIFY THE REGION TOO**. 21 | In the case of British, specifying `en` will not work, but `en_GB` will. 22 | 23 | ## Install 24 | 25 | [npm][]: 26 | 27 | ```bash 28 | npm install osx-learn --global 29 | ``` 30 | 31 | ## Usage 32 | 33 | ```text 34 | Usage: learn [options] [language] 35 | 36 | Options: 37 | 38 | -h, --help output usage information 39 | -v, --version output version 40 | 41 | Examples: 42 | 43 | $ learn npm 44 | $ learn stringification en_GB 45 | 46 | See also: man 1 learn 47 | ``` 48 | 49 | ## License 50 | 51 | [MIT][] © [Titus Wormer][author] 52 | 53 | [bash]: https://img.shields.io/badge/bin-sh-89e051.svg 54 | [npm]: https://docs.npmjs.com/cli/install 55 | [mit]: license 56 | [author]: https://wooorm.com 57 | --------------------------------------------------------------------------------