Skip to content

Commit

Permalink
Merge pull request pimterry#71 from ingkebil/fix-completion
Browse files Browse the repository at this point in the history
Fix autocompletion for search, ls & short-form commands
  • Loading branch information
pimterry authored Jul 2, 2019
2 parents 1fb3d4f + 1ec25b7 commit 00f9e66
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
13 changes: 8 additions & 5 deletions notes.bash_completion
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ _notes_complete_notes() {
}

_notes_complete_commands() {
local valid_commands="new find grep open ls rm cat"
local valid_commands="new find grep open ls rm cat search"
COMPREPLY=($(compgen -W "${valid_commands}" -- "${1}"))
}

Expand All @@ -34,18 +34,21 @@ _notes()

if [[ $COMP_CWORD -gt 1 ]]; then
case "${COMP_WORDS[1]}" in
new)
new|n)
_notes_complete_notes "$cur"
;;
find)
find|f)
_notes_complete_notes "$cur"
;;
grep)
;;
open)
open|o)
_notes_complete_notes "$cur"
;;
cat)
cat|c)
_notes_complete_notes "$cur"
;;
ls)
_notes_complete_notes "$cur"
;;
esac
Expand Down
1 change: 1 addition & 0 deletions test/test-bash-completion.bats
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ teardown() {
assert_contains "open" "${COMPREPLY[@]}"
assert_contains "ls" "${COMPREPLY[@]}"
assert_contains "rm" "${COMPREPLY[@]}"
assert_contains "search" "${COMPREPLY[@]}"
}

@test "Should show matching note when found" {
Expand Down

0 comments on commit 00f9e66

Please sign in to comment.