Skip to content

Commit 6323faa

Browse files
author
Linus Wallgren
committed
bash-completion: ignore hidden files
1 parent 7b1fa74 commit 6323faa

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

notes.bash_completion

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _notes_complete_notes() {
88
local items=($(compgen -f "$notes_dir/$1" | sort ))
99
IFS="$OLD_IFS"
1010
for item in "${items[@]}"; do
11+
[[ $item =~ /\.[^/]*$ ]] && continue
1112
[[ -d $item ]] && item="$item/"
1213
local filename=${item#$notes_dir/}
1314
COMPREPLY+=("${filename%.md}")

test/test-bash-completion.bats

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,11 @@ teardown() {
4444
assert_equal "${COMPREPLY[0]}" 'my note'
4545
assert_equal 1 "${#COMPREPLY[@]}"
4646
}
47+
48+
@test "Should ignore hidden files" {
49+
touch "$NOTES_DIRECTORY/note1.md"
50+
touch "$NOTES_DIRECTORY/.hiddennote.md"
51+
_notes_complete_notes ""
52+
assert_equal "${COMPREPLY[0]}" 'note1'
53+
assert_equal 1 "${#COMPREPLY[@]}"
54+
}

0 commit comments

Comments
 (0)