Skip to content

Commit

Permalink
Make sure we get the right error if no editor is available
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry committed Dec 2, 2016
1 parent 1df7bd2 commit 5aa0ce5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions notes
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#!/bin/bash

EDITOR=${EDITOR:-editor}

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

# If no $EDITOR, look for `editor` (symlink on debian/ubuntu/etc)
if [ -z $EDITOR ] && type editor &>/dev/null; then
EDITOR=editor
fi

without_notes_dir() {
cat | sed -e s/^$escaped_notes_dir//g | sed -E "s/^\/+//g"
}
Expand Down
1 change: 1 addition & 0 deletions test/test-open.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ notes="./notes"
run $notes open test

assert_failure
assert_output "Please set \$EDITOR to edit notes"
}

@test "Opens the configured notes directory if set" {
Expand Down

0 comments on commit 5aa0ce5

Please sign in to comment.