Skip to content

Commit 5aa0ce5

Browse files
committed
Make sure we get the right error if no editor is available
1 parent 1df7bd2 commit 5aa0ce5

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

notes

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#!/bin/bash
22

3-
EDITOR=${EDITOR:-editor}
4-
53
configured_dir=${NOTES_DIRECTORY%/} # Remove trailing slashes
64
notes_dir="${configured_dir:-$HOME/notes}"
75
escaped_notes_dir=$(printf $notes_dir | sed -e 's/[]\/$*.^|[]/\\&/g')
86

7+
# If no $EDITOR, look for `editor` (symlink on debian/ubuntu/etc)
8+
if [ -z $EDITOR ] && type editor &>/dev/null; then
9+
EDITOR=editor
10+
fi
11+
912
without_notes_dir() {
1013
cat | sed -e s/^$escaped_notes_dir//g | sed -E "s/^\/+//g"
1114
}

test/test-open.bats

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ notes="./notes"
3434
run $notes open test
3535

3636
assert_failure
37+
assert_output "Please set \$EDITOR to edit notes"
3738
}
3839

3940
@test "Opens the configured notes directory if set" {

0 commit comments

Comments
 (0)