Skip to content

Commit d04b6de

Browse files
authored
Merge pull request #76 from eshapard/patch-1
Make `ls` ignore vim backup files
2 parents 82db972 + 604a58f commit d04b6de

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Searches all note content and note filenames for the given string and returns al
109109

110110
### `notes ls <directory>`
111111

112-
Lists note names and note directories at a single level. Lists all top level notes and directories if no path is provided, or the top-level contents of a directory if one is provided.
112+
Lists note names and note directories at a single level. Lists all top level notes and directories if no path is provided, or the top-level contents of a directory if one is provided. Automatically ignores hidden files or filenames ending with `~` (Vim backup files).
113113

114114
### `notes open`
115115

notes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ without_notes_dir() {
3131
}
3232

3333
ls_notes() {
34-
local ls_output=$(ls -p "$notes_dir/$*" 2>&1)
34+
local ls_output=$(ls -p "$notes_dir/$*" 2>&1 | grep -v "~$")
3535
local ls_result=$?
3636
local formatted_output
3737

test/test-ls.bats

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ notes="./notes"
3030
assert_line "note2.md"
3131
}
3232

33+
@test "Should not list temporary files" {
34+
touch $NOTES_DIRECTORY/note1.md
35+
touch $NOTES_DIRECTORY/note1.md~
36+
touch $NOTES_DIRECTORY/note2~with~tilde.md
37+
38+
run $notes ls
39+
assert_success
40+
41+
assert_line "note1.md"
42+
assert_line "note2~with~tilde.md"
43+
44+
refute_line "note1.md~"
45+
}
46+
3347
@test "Should list subdirectories with trailing slash" {
3448
touch $NOTES_DIRECTORY/match-note1.md
3549
mkdir $NOTES_DIRECTORY/match-dir

0 commit comments

Comments
 (0)