Skip to content

feat(memo): replace custom omemo with mattn/memo template#80

Merged
edge2992 merged 3 commits into
mainfrom
feat/memo-template
May 5, 2026
Merged

feat(memo): replace custom omemo with mattn/memo template#80
edge2992 merged 3 commits into
mainfrom
feat/memo-template

Conversation

@edge2992
Copy link
Copy Markdown
Owner

@edge2992 edge2992 commented May 5, 2026

Summary

  • Delete dot_local/bin/omemo (custom shell script that duplicated mattn/memo's functionality).
  • Wire up mattn/memo's built-in template feature instead, by bringing ~/.config/memo/ under chezmoi management.
  • Parameterize the memo vault path via a new chezmoi template variable memo_dir so the public repo no longer hardcodes a personal vault name.

Changes

File Change Purpose
dot_local/bin/omemo deleted Functionality moved to memo template
private_dot_config/memo/template.md added mattn/memo template ({{.Title}}, {{.Date}}) producing the same YAML frontmatter omemo did
private_dot_config/memo/config.toml.tmpl added chezmoi-managed memo config; memodir and memotemplate use ${HOME} and {{ .memo_dir }}
.chezmoi.yaml.tmpl +1 prompt New memo_dir data var (default Documents/memo/_posts)
.pre-commit-config.yaml exclude .chezmoi.yaml.tmpl The hook calls chezmoi execute-template which doesn't know promptStringOnce

Why this approach

  1. mattn/memo is already installed via run_once_install-linux-packages.sh.tmpl:59. Its memotemplate config supports the exact use case the omemo script was solving.
  2. Per mattn/memo README, memodir/memotemplate accept ${HOME} and ~/ — using ${HOME} makes the path portable across machines without hardcoding /home/<user> or /Users/<user>.
  3. The vault name ob_edgissa is personal; moving it to a chezmoi prompt keeps it out of git while letting first-time chezmoi init set it up.

Post-merge steps (for me)

After merging:

# Add memo_dir to personal chezmoi config
$EDITOR ~/.config/chezmoi/chezmoi.yaml
#   data:
#     memo_dir: "Documents/ob_edgissa/memo/_posts"

chezmoi diff   # confirms config.toml + template.md additions
chezmoi apply
memo new "test"   # smoke test — should open nvim with frontmatter

A separate cleanup is needed: branch fix/omemo-executable-prefix was an earlier (now superseded) attempt to keep the script. It should be deleted with git push origin --delete fix/omemo-executable-prefix after this PR is merged.

Test plan

  • make lint passes
  • pre-commit run --all-files passes for changed files
  • chezmoi execute-template < private_dot_config/memo/config.toml.tmpl renders cleanly with default and after memo_dir is set
  • After merge: memo new "test" produces a markdown file with the expected frontmatter at \$memo_dir

edge2992 added 3 commits May 5, 2026 10:55
The omemo bash script duplicated functionality already provided by
mattn/memo (already installed via run_once_install-linux-packages).
Replace it with a memotemplate file that produces the same YAML
frontmatter, and bring ~/.config/memo/config.toml under chezmoi
management so the template is wired up declaratively.

- Delete dot_local/bin/omemo
- Add private_dot_config/memo/config.toml (memotemplate pointing to
  template.md; existing values preserved with ~/ prefix)
- Add private_dot_config/memo/template.md (Go text/template with
  {{.Title}} and {{.Date}})
Address two issues raised on the previous commit:

- Hardcoded `~/Documents/ob_edgissa/memo/_posts` leaked a personal
  vault name into the public dotfiles repo. Parameterize via a new
  chezmoi template variable `memo_dir` (prompted on init, default
  `Documents/memo/_posts`). Personal value is stored in the user's
  out-of-repo `~/.config/chezmoi/chezmoi.yaml`.
- Switch `~/` prefix to `${HOME}/` for portable home expansion;
  mattn/memo expands env vars at runtime.

Side effect: exclude `.chezmoi.yaml.tmpl` from the
`chezmoi-template-check` pre-commit hook — it uses init-only
functions (e.g. `promptStringOnce`) that plain
`chezmoi execute-template` does not recognize, so the hook would
otherwise fail on any change to that file.
`promptStringOnce` opens /dev/tty unconditionally and fails in
GitHub Actions runners (no TTY). Wrap the new memo_dir prompt
in the same `if env "CI"` pattern used by op_account, so CI
falls through to the default path without prompting.
@edge2992 edge2992 merged commit 8e4cb44 into main May 5, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant