Skip to content

Commit

Permalink
Merge pull request pimterry#62 from apatil/master
Browse files Browse the repository at this point in the history
Add ability to create quicknote in a subfolder
  • Loading branch information
pimterry authored Sep 25, 2018
2 parents 1275e51 + ce40ac0 commit d425469
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ There are also more complex options available. You can set any configuration pro

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

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`.
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`). If you want to place a quicknote in a subfolder, use a trailing slash: `notes new subfolder/`. Shorthand alias also available with `notes n`.

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

Expand Down
5 changes: 5 additions & 0 deletions notes
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ new_note() {
if [[ $note_name == "" ]]; then
note_name="$(generate_name)"
fi

if echo "$note_name" | grep "/$" &> /dev/null; then
note_name="${note_name}/$(generate_name)"
fi

mkdir -p "$(dirname "$notes_dir/$note_name")"

open_note "$note_name"
Expand Down
8 changes: 8 additions & 0 deletions test/test-new.bats
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ notes="./notes"
assert_success
assert_exists "$NOTES_DIRECTORY/notes with spaces/note.md"
}

@test "Should create quicknote in a subfolder" {
today=`date "+%Y-%m-%d"`
run $notes new subfolder/

assert_success
assert_exists "$NOTES_DIRECTORY/subfolder/quicknote-$today.md"
}

0 comments on commit d425469

Please sign in to comment.