adds command to create note
This commit is contained in:
parent
64879ac366
commit
25bcbddb73
2 changed files with 42 additions and 1 deletions
|
|
@ -54,6 +54,47 @@
|
||||||
vterm_printf = ''
|
vterm_printf = ''
|
||||||
printf "\e]%s\e\\" "$argv"
|
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 = ''
|
interactiveShellInit = ''
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ function M.project_dirs()
|
||||||
table.insert(projects, dir)
|
table.insert(projects, dir)
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(projects, wezterm.home_dir .. "/orgnzr")
|
table.insert(projects, wezterm.home_dir .. "/notes")
|
||||||
|
|
||||||
return projects
|
return projects
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue