Skip to content

Commit d425469

Browse files
authored
Merge pull request #62 from apatil/master
Add ability to create quicknote in a subfolder
2 parents 1275e51 + ce40ac0 commit d425469

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ There are also more complex options available. You can set any configuration pro
9393

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

96-
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`.
96+
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`.
9797

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

notes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ new_note() {
118118
if [[ $note_name == "" ]]; then
119119
note_name="$(generate_name)"
120120
fi
121+
122+
if echo "$note_name" | grep "/$" &> /dev/null; then
123+
note_name="${note_name}/$(generate_name)"
124+
fi
125+
121126
mkdir -p "$(dirname "$notes_dir/$note_name")"
122127

123128
open_note "$note_name"

test/test-new.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@ notes="./notes"
7373
assert_success
7474
assert_exists "$NOTES_DIRECTORY/notes with spaces/note.md"
7575
}
76+
77+
@test "Should create quicknote in a subfolder" {
78+
today=`date "+%Y-%m-%d"`
79+
run $notes new subfolder/
80+
81+
assert_success
82+
assert_exists "$NOTES_DIRECTORY/subfolder/quicknote-$today.md"
83+
}

0 commit comments

Comments
 (0)