Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 8, 2015
0 parents commit 21dca3b
Show file tree
Hide file tree
Showing 7 changed files with 239 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
*.log
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
(The MIT License)

Copyright (c) 2015 Titus Wormer <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
60 changes: 60 additions & 0 deletions man/learn.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.TH "learn" "1" "August 2015" "0.0.0" ""

.SH "NAME"
\fBlearn\fR - Add words to the OS X Spell Check dictionary

.SH "SYNOPSIS"
.P
\fBlearn\fR \[lB]\fBoptions\fR\[rB] <\fIword\fR> \[lB]\fBlanguage\fR\[rB]

.SH "DESCRIPTION"
.P
\fBlearn\fR(1) adds words to OS X\(cqs valid words list, as in, remove warnings
about words like \(ganpm\(ga.

If a language is specified, the language designator (ISO 639-1 or ISO 639-2)
must be lower-case, e.g., \(ganl\(ga. When a region designator (ISO 3166-1) is
added, it must be all-caps and preceded by an underscore, e.g., \(gaen_GB\(ga.

.SH "EXAMPLE"
.RS 2
.nf
\(Do learn npm
.fi
.nf
\(Do learn stringification en_GB
.fi
.RE

.SH "OPTIONS"

.SS "-v, --version"
.P
output version

.SS "-h, --help"
.P
output usage information

.SH "NOTE"
.P
Ensure the language is enabled in \(gaSystem Preferences\(ga > \(gaKeyboard\(ga
> \(gaText\(ga > \(gaSpelling\(ga > \(gaSet Up...\(ga.

.P
When adding a word to a language which has region designators (such as English,
which has British and more), \fBYOU MUST SPECIFY THE REGION TOO\fR.
In the case of British, specifying \(gaen\(ga will not work, but \(gaen_GB\(ga
will.

.SH "BUGS"
.P
<\fIhttps://github.com/wooorm/osx-learn/issues\fR>

.SH "AUTHOR"
.P
Written by Titus Wormer <\fI[email protected]\fR>

.SH "LICENSE"
.P
MIT \(co Titus Wormer
63 changes: 63 additions & 0 deletions osx-learn.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/sh

#
# Usage.
#

usage () {
cat << EOF
Usage: learn [options] <word> [language]
Options:
-h, --help output usage information
-v, --version output version
Examples:
$ learn npm
$ learn stringification en_GB
See also: man 1 learn
EOF
}

#
# Version.
#

version () {
echo "0.0.0"
}

#
# Options.
#

case $1 in
"") usage; exit 1 ;;
-h|--help) usage; exit ;;
-v|--version) version; exit ;;
*) readonly replace=$1 ; readonly lang=${2-"LocalDictionary"} ;;
esac

#
# Find list.
#

database=~/Library/Spelling/$lang

touch "$database"

echo "$1" >> $database

data=$(cat $database | sort)

echo "$data" > $database

#
# Restart AppleSpell.
#

killall -e AppleSpell &> /dev/null
31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "osx-learn",
"version": "0.0.0",
"description": "Add words to the OS X Spell Check dictionary",
"license": "MIT",
"keywords": [
"cli",
"bin",
"mac",
"osx",
"learn",
"spelling",
"corrent"
],
"repository": "wooorm/osx-learn",
"author": {
"name": "Titus Wormer",
"email": "[email protected]",
"url": "http://wooorm.com"
},
"files": [
"osx-learn.sh",
"man"
],
"bin": {
"learn": "osx-learn.sh"
},
"directories": {
"man": "./man"
}
}
49 changes: 49 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# osx-learn ![`bin/sh`](https://img.shields.io/badge/bin-sh-89e051.svg)

> Add words to OS X’s valid words list, as in, remove warnings about words
> like `npm`.
Tested on OS X 10.10 (Yosemite), might work earlier.

If a language is specified, the language designator (ISO 639-1 or
[ISO 639-2](https://github.com/wooorm/iso-639-2/blob/master/Support.md))
must be lower-case, e.g., `nl`.
When a region designator (ISO 3166-1) is added, it must be all-caps and
preceded by an underscore, e.g., `en_GB`.

Ensure the language is enabled in `System Preferences` > `Keyboard` >
`Text` > `Spelling` > `Set Up...`.

When adding a word to a language which has region designators (such as English,
which has British and more), **YOU MUST SPECIFY THE REGION TOO**.
In the case of British, specifying `en` will not work, but `en_GB` will.

## Install

[npm](https://docs.npmjs.com/cli/install):

```bash
npm install osx-learn --global
```

## Usage

```text
Usage: learn [options] <word> [language]
Options:
-h, --help output usage information
-v, --version output version
Examples:
$ learn npm
$ learn stringification en_GB
See also: man 1 learn
```

## License

[MIT](LICENSE) © [Titus Wormer](http://wooorm.com)

0 comments on commit 21dca3b

Please sign in to comment.