diff --git a/README.md b/README.md index 3b31332..241263f 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,8 @@ and will open that note file in Vim. - Use the `-d` flag to move a file into trash (`$NOTE_DIR/trash`) - `--destroy ` - Use the `--destroy` flag to permanently delete a note. +- `-l | --list []` + - Use this `--list` flag to list note files. Defaults to `.md` files if no extension is specified. ## Demo (Asciinema) diff --git a/note.bash b/note.bash index f941b79..158571b 100755 --- a/note.bash +++ b/note.bash @@ -35,7 +35,7 @@ create_note() { } print_help() { - printf "Notekeeper 1.1 (11 May 2021) + printf "Notekeeper 1.2 (10 November 2021) Usage: note [] @@ -50,6 +50,8 @@ Arguments: -t | --time Add a timestamp when opening a note. -d | --delete Move a note to the trash directory. --destroy Permanently delete (rm) a note. + -l | --list [] List note files. Defaults to .md files + if no file extension is specified. Notekeeper loads configuration variables from: \$HOME/.config/notekeeper/noterc. @@ -133,6 +135,10 @@ destroy_note() { fi } +list_notes() { + find "$BASE_NOTE_DIR" -type f -name "*$1" | sed "s@.*/@@" | sort +} + openNote=false printNoteOnly=false createNoteOnly=false @@ -201,6 +207,15 @@ if (($# > 0)); then destroy_note "$2" exit 0 ;; + -l | --list) + if [ "$#" -eq 2 ]; then + file_extension=$2 + else + file_extension=".md" + fi + list_notes $file_extension + exit 0 + ;; *) printf "Unknown Argument \"%s\"\n" "$1" printf "Use \"note --help\" to see usage information.\n"