46 lines
827 B
Bash
Executable File
46 lines
827 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -e
|
|
set -o pipefail
|
|
|
|
# Notes listing tool
|
|
#
|
|
# Purpose:
|
|
# Lists all markdown notes stored in ~/notes/ directory
|
|
#
|
|
# Usage:
|
|
# notes - Display all available notes
|
|
#
|
|
# Output:
|
|
# - Shows filenames of all .md files in ~/notes/
|
|
# - If no notes exist or directory is empty, displays "Empty"
|
|
# - Provides hint to use 'note -e' for editing
|
|
#
|
|
# Example output:
|
|
# 1703123456-my-idea.md
|
|
# 1703123789-shopping-list.md
|
|
# 1703124012-project-notes.md
|
|
#
|
|
# Use 'note -e' to edit existing notes
|
|
|
|
path="$HOME/notes"
|
|
|
|
[[ ! -d "$path" ]] && {
|
|
echo "Empty"
|
|
exit 0
|
|
}
|
|
|
|
shopt -s nullglob
|
|
files=("$path"/*.md)
|
|
shopt -u nullglob
|
|
|
|
[[ "${#files}" -eq 0 ]] && {
|
|
echo "Empty"
|
|
exit 0
|
|
}
|
|
for file in "${files[@]}"; do
|
|
echo "${file/$path\//}"
|
|
done
|
|
|
|
echo
|
|
echo "Use 'note -e' to edit existing notes"
|