diff --git a/modules/fish/work.nix b/modules/fish/work.nix index b544b51..061c4dc 100644 --- a/modules/fish/work.nix +++ b/modules/fish/work.nix @@ -141,6 +141,47 @@ pr_comments = '' gh api repos/digital-h-gmbh/ride/pulls/$argv/comments | jq -r '.[] | "- [ ] Fix \nnvim +\(.line) \(.path)\n\"\(.body)\"\n\n"' >./pr-comments.md && nvim ./pr-comments.md ''; + 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 + ''; fish_mode_prompt = '' switch $fish_bind_mode case default