File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -51,13 +51,24 @@ open_something() {
51
51
while read note_name; do
52
52
open_note " $note_name "
53
53
done <<< " $note_names"
54
+ elif [ $# -gt 0 ]; then
55
+ open_note " $* "
54
56
else
55
57
open $notes_dir
56
58
fi
57
59
}
58
60
59
61
open_note () {
60
- $EDITOR " $notes_dir /$1 " < /dev/tty
62
+ note_path=$1
63
+
64
+ if [[ " $note_path " != * .md ]]; then
65
+ note_path=" $note_path .md"
66
+ fi
67
+ if [ ! -f " $note_path " ]; then
68
+ note_path=" $notes_dir /$note_path "
69
+ fi
70
+
71
+ $EDITOR " $note_path " < /dev/tty
61
72
}
62
73
63
74
usage () {
Original file line number Diff line number Diff line change @@ -53,4 +53,22 @@ notes="./notes"
53
53
assert_success
54
54
assert_line " Editing $NOTES_DIRECTORY /note.md"
55
55
assert_line " Editing $NOTES_DIRECTORY /note2.md"
56
+ }
57
+
58
+ @test " Accepts relative notes paths to open" {
59
+ touch $NOTES_DIRECTORY /note.md
60
+
61
+ run bash -c " $notes open note.md"
62
+
63
+ assert_success
64
+ assert_output " Editing $NOTES_DIRECTORY /note.md"
65
+ }
66
+
67
+ @test " Accepts names without .md to open" {
68
+ touch $NOTES_DIRECTORY /note.md
69
+
70
+ run bash -c " $notes open note"
71
+
72
+ assert_success
73
+ assert_output " Editing $NOTES_DIRECTORY /note.md"
56
74
}
You can’t perform that action at this time.
0 commit comments