diff --git a/modules/fish/default.nix b/modules/fish/default.nix index 8ed7a8d..8d1312c 100644 --- a/modules/fish/default.nix +++ b/modules/fish/default.nix @@ -54,6 +54,47 @@ vterm_printf = '' printf "\e]%s\e\\" "$argv" ''; + nn = '' + # Require a title argument + if test (count $argv) -lt 1 + echo "Usage: nn \"My Note\"" + return 1 + end + + # Join all arguments into single title (preserves spaces inside quotes) + set -l title $argv[1] + + # Timestamp up to minutes, format: YYYY-MM-DD_HH-MM + set -l ts (date "+%Y%m%d%H%M") + + # Normalize title: lowercase, replace spaces with hyphens, remove/replace + # characters unsafe for filenames (keep a-z0-9- and replace others with -) + set -l slug (string lower -- $title) + # Replace any sequence of non-alphanumeric characters with single hyphen + set -l slug (echo $slug | sed -E 's/[^a-z0-9]+/-/g' | sed -E 's/^-|-$//g') + + # Compose filename + set -l filename "$ts_$slug.md" + + # Directory for notes (change if you prefer another path) + set -l notes_dir ~/notes + + # Ensure directory exists + test -d $notes_dir; or mkdir -p $notes_dir + + # Full path + set -l fullpath "$notes_dir/$filename" + + # If file doesn't exist, create with timestamp and title at top + if not test -f $fullpath + # Human-friendly timestamp line (no seconds) + set -l display_ts (date "+%Y-%m-%d %H:%M") + printf "---\nCREATED_AT: %s\n---\n\n# %s\n\n" "$display_ts" "$title" > $fullpath + end + + # Open file in neovim + nvim $fullpath + ''; }; interactiveShellInit = '' diff --git a/modules/wezterm/config/helpers.lua b/modules/wezterm/config/helpers.lua index 225ca11..7eaf8bf 100644 --- a/modules/wezterm/config/helpers.lua +++ b/modules/wezterm/config/helpers.lua @@ -13,7 +13,7 @@ function M.project_dirs() table.insert(projects, dir) end - table.insert(projects, wezterm.home_dir .. "/orgnzr") + table.insert(projects, wezterm.home_dir .. "/notes") return projects end