Skip to content

Commit 87a96e7

Browse files
committed
Various small tweaks to README and code style
1 parent 51a70ec commit 87a96e7

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

README.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Download `notes`, `chmod +x`, put it in your `$path`. This will probably do it:
2727
curl https://cdn.rawgit.com/pimterry/notes/v0.2.0/notes > /usr/local/bin/notes && chmod +x /usr/local/bin/notes
2828
```
2929

30-
By default your notes live in ~/notes, but you can change that to anywhere you like by setting the `$NOTES_DIRECTORY` environmental variable.
30+
By default your notes live in ~/notes, but you can change that to anywhere you like by setting the `$NOTES_DIRECTORY` environmental variable. See [how do I configure this?](#how-do-i-configure-this) for more details.
3131

3232
#### Installing Bash completion
3333

@@ -47,22 +47,17 @@ You'll need to open a new shell for this to take effect.
4747

4848
## How do I configure this?
4949

50-
You can set your favourite text editor and your notes directory by setting the `$EDITOR` and `$NOTES_DIRECTORY` environmental variables.
50+
To get started with you'll want to set `$EDITOR` to your favourite text editor, and probably `$NOTES_DIRECTORY` to the directory in which you'd like to use to store your notes (this defaults to `~/notes`). You'll typically want to set these as environment variables in your `.bashrc`, `.zshrc`, or similar.
5151

52-
You can also set `$QUICKNOTE_FORMAT` to change the way that quicknotes are generated. The string is formatted using the `date` command.
52+
There are also more complex options available. You can set any configuration properties either in the environment, or in a config file (stored in `~/.config/notes/config`), with settings in config overriding those in your environment. This allows you to configure a different `$EDITOR` for notes to everything else, if you like. The config file is a good choice for more complex set ups, but probably not worth worrying about to start with. We've included an example config in this repo for you ([config.example](config.example)) that you can copy if you like.
5353

54-
Most users shouldn't need to do any more than that. If you're doing anything more complicated though, you can configure `notes` config directly in "~/.config/notes/config", including EDITOR and NOTES_DIRECTORY. We've included an example in this repo for you ([config.example](config.example)) that you can copy. Any values set in the config file override values in environment variables.
55-
56-
Right now this mainly exists in case you want to use a different `EDITOR` for notes than the one you have set in your environment generally, but this is where all other config will be living in future.
54+
The only other configuration property right now is `$QUICKNOTE_FORMAT`, which changes the way that quicknote filenames are generated. The string is formatted by passing it to the `date` command, and defaults to `quicknote-%Y-%m-%d`.
5755

5856
## How do I use it?
5957

6058
### `notes new <note-name>`
6159

62-
Opens your `$EDITOR` of choice for a new note, with the given name. The name can include slashes, if you want to put your note in a subfolder. Shorthand alias also available with `notes n`.
63-
64-
### `notes new`
65-
Creates a quicknote with the name of the format `quicknote-YYYY-MM-DD.md`. This can be changed in the configuration file.
60+
Opens your `$EDITOR` of choice for a new note, with the given name. The name can include slashes, if you want to put your note in a subfolder. Leave out the name if you want one to be generated for you (e.g. `quicknote-2016-12-21.md` - format configurable with `$QUICKNOTE_FORMAT`). Shorthand alias also available with `notes n`.
6661

6762
### `notes find <part-of-a-note-name>`
6863

notes

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,30 +93,31 @@ grep_notes() {
9393
return 2
9494
fi
9595
}
96+
9697
generate_name() {
9798
local append_num=0
9899
local format_string="`date +$QUICKNOTE_FORMAT`"
99100
# Initial test has no append
100-
resolved_name=$format_string
101+
local resolved_name=$format_string
101102
while [[ -e "$notes_dir/$resolved_name.md" ]]
102103
do
103104
append_num=$[$append_num+1]
104105
resolved_name=$format_string.$append_num
105106
done
107+
printf $resolved_name
106108
}
107109

108110
new_note() {
109111
local note_name="$*"
110112
if [[ $note_name == "" ]]; then
111-
generate_name
112-
note_name=$resolved_name
113+
note_name="$(generate_name)"
113114
fi
114115
mkdir -p "$(dirname "$notes_dir/$note_name")"
115116
open_note "$note_name.md"
116117
}
117118

118119
remove_note() {
119-
local rm_arga=()
120+
local rm_args=()
120121
if [[ "$1" == "-r" || "$1" == "--recursive" ]]; then
121122
rm_args+=("--recursive")
122123
shift

test/test-config.bats

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ load 'helpers'
77
setup() {
88
setupNotesEnv
99
}
10+
1011
teardown() {
1112
teardownNotesEnv
1213
}
14+
1315
export EDITOR=touch
1416
notes="./notes"
1517

16-
1718
@test "Configuration should override QUICKNOTE_FORMAT" {
1819
mkdir -p $HOME/.config/notes
1920
echo "QUICKNOTE_FORMAT=test" > $HOME/.config/notes/config

0 commit comments

Comments
 (0)