Help us shape the future of Go! Take the 2026 Go Developer Survey

notmuch2maildir

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2026 License: BSD-3-Clause

README

notmuch2maildir

CI Go Version Go Report Card License Release

A simple CLI tool written in Go for searching your mails in a MUA like neomutt or mutt using the notmuch mail indexer.

The idea is based on the original version of the mutt-notmuch script and mutt-notmuch-py. The implementation in Go is - for large search results - significantly faster.

Installation

Go install
go install github.com/timorunge/notmuch2maildir/cmd/notmuch2maildir@latest
Binary download

Download pre-built binaries for your platform from the releases page.

Build from source
git clone https://github.com/timorunge/notmuch2maildir.git
cd notmuch2maildir
make build

Quick Start

For the usage it's required that notmuch itself is in your $PATH (or use --notmuch-executable to specify the path).

Search your mail:

notmuch2maildir "from:alice subject:meeting"

Reconstruct a full thread from a message:

notmuch2maildir -t -m "<message-id>"

Usage

notmuch2maildir - Search mail and reconstruct threads using notmuch

Usage:
  notmuch2maildir [OPTIONS] QUERY
  notmuch2maildir -p
  notmuch2maildir -t -m <message-id>
  notmuch2maildir -t < email.eml

Options:
  -t, --thread                      Thread mode: reconstruct a full mail thread
  -p, --prompt                      Open a prompt to enter the search query
  -m, --message-id string           Message-ID for thread reconstruction
      --notmuch-config string       notmuch configuration file (default: notmuch's own resolution)
      --output-dir string           Output directory for search results (default "$XDG_CACHE_HOME/notmuch/search_results")
      --notmuch-executable string   Path to notmuch binary (default "notmuch")
  -h, --help                        Show this help message
      --version                     Show the version of notmuch2maildir
Configuration

By default, notmuch2maildir lets notmuch resolve its own configuration using its built-in search order:

  1. --notmuch-config flag (passed through as notmuch --config)
  2. NOTMUCH_CONFIG environment variable
  3. $XDG_CONFIG_HOME/notmuch/<profile>/config (or default if no profile)
  4. $HOME/.notmuch-config

Most users don't need --notmuch-config at all.

Search mode is the default. Pass your query as positional arguments:

notmuch2maildir "from:alice subject:meeting"
notmuch2maildir from:bob date:2024..

Use -- to separate queries that start with a dash:

notmuch2maildir -- -tag:spam from:alice

Use -p / --prompt for interactive input:

notmuch2maildir -p
Thread

Thread mode (-t / --thread) reconstructs a full mail thread. Provide the message-id via -m or pipe a mail to stdin:

notmuch2maildir -t -m "<message-id>"
notmuch2maildir -t < email.eml

(neo)mutt configuration

Choose the interactive or the query mode and add the following snippets to your muttrc.

Search
Prompt mode
macro index / "<enter-command>unset wait_key<enter><shell-escape>notmuch2maildir -p<enter><change-folder-readonly>~/.cache/notmuch/search_results<enter>" \
            "Search mail (using notmuch)"
Query mode
macro index / "<enter-command>unset wait_key<enter><shell-escape>read -p 'Search query: ' query; notmuch2maildir \$query<enter><change-folder-readonly>~/.cache/notmuch/search_results<enter>" \
            "Search mail (using notmuch)"
Reconstruct thread
macro index T "<enter-command>unset wait_key<enter><pipe-message>notmuch2maildir -t<enter><change-folder-readonly>~/.cache/notmuch/search_results<enter>" \
            "Search and reconstruct thread (Using notmuch)"

Development

make build    # Build the binary
make test     # Run tests with race detector
make check    # All quality gates: fmt + tidy + vet + lint + test
make help     # See all available targets

License

BSD 3-Clause "New" or "Revised" License

Directories

Path Synopsis
cmd
notmuch2maildir command
Package main provides the notmuch2maildir CLI entry point.
Package main provides the notmuch2maildir CLI entry point.
internal
nm2md
Package nm2md implements notmuch search-to-maildir conversion.
Package nm2md implements notmuch search-to-maildir conversion.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL