]> git.notmuchmail.org Git - notmuch/blob - notmuch.1
TODO: Note that "notmuch reply" needs to be tested.
[notmuch] / notmuch.1
1 .\" notmuch - Not much of an email program, (just index, search and tagging)
2 .\"
3 .\" Copyright © 2009 Carl Worth
4 .\"
5 .\" Notmuch is free software: you can redistribute it and/or modify
6 .\" it under the terms of the GNU General Public License as published by
7 .\" the Free Software Foundation, either version 3 of the License, or
8 .\" (at your option) any later version.
9 .\"
10 .\" Notmuch is distributed in the hope that it will be useful,
11 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
12 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 .\" GNU General Public License for more details.
14 .\"
15 .\" You should have received a copy of the GNU General Public License
16 .\" along with this program.  If not, see http://www.gnu.org/licenses/ .
17 .\"
18 .\" Author: Carl Worth <cworth@cworth.org>
19 .TH NOTMUCH 1 2009-10-31 "Notmuch 0.1"
20 .SH NAME
21 notmuch \- thread-based email index, search, and tagging
22 .SH SYNOPSIS
23 .B notmuch
24 .IR command " [" args " ...]"
25 .SH DESCRIPTION
26 Notmuch is a command-line based program for indexing, searching,
27 reading, and tagging large collections of email messages.
28
29 The quickest way to get started with Notmuch is to simply invoke the
30 .B notmuch
31 command with no arguments, which will interactively guide you through
32 the process of indexing your mail.
33 .SH NOTE
34 While the command-line program
35 .B notmuch
36 provides powerful functionality, it does not provide the most
37 convenient interface for that functionality. More sophisticated
38 interfaces are expected to be built on top of either the command-line
39 interface, or more likely, on top of the notmuch library
40 interface. See http://notmuchmail.org for more about alternate
41 interfaces to notmuch.
42 .SH COMMANDS
43 The
44 .BR setup
45 command is used to configure Notmuch for first use, (or to reconfigure
46 it later).
47 .RS 4
48 .TP 4
49 .B setup
50
51 Interactively sets up notmuch for first use.
52
53 The setup command will prompt for your full name, your primary email
54 address, any alternate email addresses you use, and the directory
55 containing your email archives. Your answers will be written to a
56 configuration file in ${NOTMUCH_CONFIG} (if set) or
57 ${HOME}/.notmuch-config . This configuration file will be created with
58 descriptive comments, making it easy to edit by hand later to change the
59 configuration. Or you can run
60 .B "notmuch setup"
61 again to change the configuration.
62
63 The mail directory you specify can contain any number of
64 sub-directories and should primarily contain only files with individual
65 email messages (eg. maildir or mh archives are perfect). If there are
66 other, non-email files (such as indexes maintained by other email
67 programs) then notmuch will do its best to detect those and ignore
68 them.
69
70 Mail storage that uses mbox format, (where one mbox file contains many
71 messages), will not work with notmuch. If that's how your mail is
72 currently stored, it is recommended you first convert it to maildir
73 format with a utility such as mb2md before running
74 .B "notmuch setup" .
75
76 Invoking
77 .B notmuch
78 with no command argument will run
79 .B setup
80 if the setup command has not previously been completed.
81 .RE
82
83 The
84 .B new
85 command is used to incorporate new mail into the notmuch database.
86 .RS 4
87 .TP 4
88 .B new
89
90 Find and import any new messages to the database.
91
92 The
93 .B new
94 command scans all sub-directories of the database, performing
95 full-text indexing on new messages that are found. Each new message
96 will automatically be tagged with both the
97 .BR inbox " and " unread
98 tags.
99
100 You should run
101 .B "notmuch new"
102 once after first running
103 .B "notmuch setup"
104 to create the initial database. The first run may take a long time if
105 you have a significant amount of mail (several hundred thousand
106 messages or more). Subsequently, you should run
107 .B "notmuch new"
108 whenever new mail is delivered and you wish to incorporate it into the
109 database. These subsequent runs will be much quicker than the initial
110 run.
111
112 Invoking
113 .B notmuch
114 with no command argument will run
115 .B new
116 if
117 .B "notmuch setup"
118 has previously been completed, but
119 .B "notmuch new"
120 has not previously been run.
121 .RE
122
123 Several of the notmuch commands accept search terms with a common
124 syntax. See the
125 .B "SEARCH SYNTAX"
126 section below for more details on the supported syntax.
127
128 The
129 .BR search " and "show
130 commands are used to query the email database.
131 .RS 4
132 .TP 4
133 .BR search " [options...] <search-term>..."
134
135 Search for messages matching the given search terms, and display as
136 results the threads containing the matched messages.
137
138 The output consists of one line per thread, giving a thread ID, the
139 date of the newest (or oldest, depending on the sort option) matched
140 message in the thread, the number of matched messages and total
141 messages in the thread, the names of all participants in the thread,
142 and the subject of the newest (or oldest) message.
143
144 Supported options for
145 .B search
146 include
147 .RS 4
148 .TP 4
149 .BR \-\-format= ( json | text )
150
151 Presents the results in either JSON or plain-text (default).
152 .RE
153 .RS 4
154 .TP 4
155 .BR \-\-sort= ( newest\-first | oldest\-first )
156
157 This option can be used to present results in either chronological order
158 .RB ( oldest\-first )
159 or reverse chronological order
160 .RB ( newest\-first ).
161
162 Note: The thread order will be distinct between these two options
163 (beyond being simply reversed). When sorting by
164 .B oldest\-first
165 the threads will be sorted by the oldest message in each thread, but
166 when sorting by
167 .B newest\-first
168 the threads will be sorted by the newest message in each thread.
169
170 .RE
171 .RS 4
172 By default, results will be displayed in reverse chronological order,
173 (that is, the newest results will be displayed first).
174
175 See the
176 .B "SEARCH SYNTAX"
177 section below for details of the supported syntax for <search-terms>.
178 .RE
179 .TP
180 .BR show " [options...] <search-term>..."
181
182 Shows all messages matching the search terms.
183
184 The messages will be grouped and sorted based on the threading (all
185 replies to a particular message will appear immediately after that
186 message in date order). The output is not indented by default, but
187 depth tags are printed so that proper indentation can be performed by
188 a post-processor (such as the emacs interface to notmuch).
189
190 Supported options for
191 .B show
192 include
193 .RS 4
194 .TP 4
195 .B \-\-entire\-thread
196
197 By default only those messages that match the search terms will be
198 displayed. With this option, all messages in the same thread as any
199 matched message will be displayed.
200 .RE
201
202 .RS 4
203 .TP 4
204 .B \-\-format=(json|text)
205
206 .RS 4
207 .TP 4
208 .B text
209
210 The default plain-text format  has  text-content  MIME parts
211 decoded. Various components in the output,
212 .RB ( message ", " header ", " body ", " attachment ", and MIME " part ),
213 will be delimited by easily-parsed markers. Each marker consists of a
214 Control-L character (ASCII decimal 12), the name of the marker, and
215 then either an opening or closing brace, ('{' or '}'), to either open
216 or close the component.
217
218 .RE
219 .RS 4
220 .TP 4
221 .B json
222
223 Format output as Javascript Object Notation (JSON). JSON output always
224 includes all messages in a matching thread; in effect
225 .B \-\-format=json
226 implies
227 .B \-\-entire\-thread
228
229 .RE
230 A common use of
231 .B notmuch show
232 is to display a single thread of email messages. For this, use a
233 search term of "thread:<thread-id>" as can be seen in the first
234 column of output from the
235 .B notmuch search
236 command.
237
238 See the
239 .B "SEARCH SYNTAX"
240 section below for details of the supported syntax for <search-terms>.
241 .RE
242 .RE
243
244 The
245 .B reply
246 command is useful for preparing a template for an email reply.
247 .RS 4
248 .TP 4
249 .BR reply " [options...] <search-term>..."
250
251 Constructs a reply template for a set of messages.
252
253 To make replying to email easier,
254 .B notmuch reply
255 takes an existing set of messages and constructs a suitable mail
256 template. The Reply-to header (if any, otherwise From:) is used for
257 the To: address. Vales from the To: and Cc: headers are copied, but
258 not including any of the current user's email addresses (as configured
259 in primary_mail or other_email in the .notmuch\-config file) in the
260 recipient list
261
262 It also builds a suitable new subject, including Re: at the front (if
263 not already present), and adding the message IDs of the messages being
264 replied to to the References list and setting the In\-Reply\-To: field
265 correctly.
266
267 Finally, the original contents of the emails are quoted by prefixing
268 each line with '> ' and included in the body.
269
270 The resulting message template is output to stdout.
271
272 Supported options for
273 .B reply
274 include
275 .RS
276 .TP 4
277 .BR \-\-format= ( default | headers\-only )
278 .RS
279 .TP 4
280 .BR default
281 Includes subject and quoted message body.
282 .TP
283 .BR headers\-only
284 Only produces In\-Reply\-To, References, To, Cc, and Bcc headers.
285 .RE
286
287 See the
288 .B "SEARCH SYNTAX"
289 section below for details of the supported syntax for <search-terms>.
290
291 Note: It is most common to use
292 .B "notmuch reply"
293 with a search string matching a single message, (such as
294 id:<message-id>), but it can be useful to reply to several messages at
295 once. For example, when a series of patches are sent in a single
296 thread, replying to the entire thread allows for the reply to comment
297 on issue found in multiple patches.
298 .RE
299 .RE
300
301 The
302 .B tag
303 command is the only command available for manipulating database
304 contents.
305
306 .RS 4
307 .TP 4
308 .BR tag " +<tag>|\-<tag> [...] [\-\-] <search-term>..."
309
310 Add/remove tags for all messages matching the search terms.
311
312 Tags prefixed by '+' are added while those prefixed by '\-' are
313 removed. For each message, tag removal is performed before tag
314 addition.
315
316 The beginning of <search-terms> is recognized by the first
317 argument that begins with neither '+' nor '\-'. Support for
318 an initial search term beginning with '+' or '\-' is provided
319 by allowing the user to specify a "\-\-" argument to separate
320 the tags from the search terms.
321
322 See the
323 .B "SEARCH SYNTAX"
324 section below for details of the supported syntax for <search-terms>.
325 .RE
326
327 The
328 .BR dump " and " restore
329 commands can be used to create a textual dump of email tags for backup
330 purposes, and to restore from that dump
331
332 .RS 4
333 .TP 4
334 .BR dump " [<filename>]"
335
336 Creates a plain-text dump of the tags of each message.
337
338 The output is to the given filename, if any, or to stdout.
339
340 These tags are the only data in the notmuch database that can't be
341 recreated from the messages themselves.  The output of notmuch dump is
342 therefore the only critical thing to backup (and much more friendly to
343 incremental backup than the native database files.)
344 .TP
345 .BR restore " <filename>"
346
347 Restores the tags from the given file (see
348 .BR "notmuch dump" "."
349
350 Note: The dump file format is specifically chosen to be
351 compatible with the format of files produced by sup-dump.
352 So if you've previously been using sup for mail, then the
353 .B "notmuch restore"
354 command provides you a way to import all of your tags (or labels as
355 sup calls them).
356 .RE
357
358 The
359 .B part
360 command can used to output a single part of a multi-part MIME message.
361
362 .RS 4
363 .TP 4
364 .BR part " \-\-part=<part-number> <search-term>..."
365
366 Output a single MIME part of a message.
367
368 A single decoded MIME part, with no encoding or framing, is output to
369 stdout. The search terms must match only a single message, otherwise
370 this command will fail.
371
372 The part number should match the part "id" field output by the
373 "\-\-format=json" option of "notmuch show". If the message specified by
374 the search terms does not include a part with the specified "id" there
375 will be no output.
376
377 See the
378 .B "SEARCH SYNTAX"
379 section below for details of the supported syntax for <search-terms>.
380 .RE
381
382 .SH SEARCH SYNTAX
383 Several notmuch commands accept a common syntax for search terms.
384
385 The search terms can consist of free-form text (and quoted phrases)
386 which will match all messages that contain all of the given
387 terms/phrases in the body, the subject, or any of the sender or
388 recipient headers.
389
390 In addition to free text, the following prefixes can be used to force
391 terms to match against specific portions of an email, (where
392 <brackets> indicate user-supplied values):
393
394         from:<name-or-address>
395
396         to:<name-or-address>
397
398         subject:<word-or-quoted-phrase>
399
400         attachment:<word>
401
402         tag:<tag> (or is:<tag>)
403
404         id:<message-id>
405
406         thread:<thread-id>
407
408 The
409 .B from:
410 prefix is used to match the name or address of the sender of an email
411 message.
412
413 The
414 .B to:
415 prefix is used to match the names or addresses of any recipient of an
416 email message, (whether To, Cc, or Bcc).
417
418 Any term prefixed with
419 .B subject:
420 will match only text from the subject of an email. Searching for a
421 phrase in the subject is supported by including quotation marks around
422 the phrase, immediately following
423 .BR subject: .
424
425 The
426 .B attachment:
427 prefix can be used to search for specific filenames (or extensions) of
428 attachments to email messages.
429
430 For
431 .BR tag: " and " is:
432 valid tag values include
433 .BR inbox " and " unread
434 by default for new messages added by
435 .B notmuch new
436 as well as any other tag values added manually with
437 .BR "notmuch tag" .
438
439 For
440 .BR id: ,
441 message ID values are the literal contents of the Message\-ID: header
442 of email messages, but without the '<', '>' delimiters.
443
444 The
445 .B thread:
446 prefix can be used with the thread ID values that are generated
447 internally by notmuch (and do not appear in email messages). These
448 thread ID values can be seen in the first column of output from
449 .B "notmuch search"
450
451 In addition to individual terms, multiple terms can be
452 combined with Boolean operators (
453 .BR and ", " or ", " not
454 , etc.). Each term in the query will be implicitly connected by a
455 logical AND if no explicit operator is provided, (except that terms
456 with a common prefix will be implicitly combined with OR until we get
457 Xapian defect #402 fixed).
458
459 Parentheses can also be used to control the combination of the Boolean
460 operators, but will have to be protected from interpretation by the
461 shell, (such as by putting quotation marks around any parenthesized
462 expression).
463
464 Finally, results can be restricted to only messages within a
465 particular time range, (based on the Date: header) with a syntax of:
466
467         <intial-timestamp>..<final-timestamp>
468
469 Each timestamp is a number representing the number of seconds since
470 1970\-01\-01 00:00:00 UTC. This is not the most convenient means of
471 expressing date ranges, but until notmuch is fixed to accept a more
472 convenient form, one can use the date program to construct
473 timestamps. For example, with the bash shell the folowing syntax would
474 specify a date range to return messages from 2009\-10\-01 until the
475 current time:
476
477         $(date +%s \-d 2009\-10\-01)..$(date +%s)
478 .SH ENVIRONMENT
479 The following environment variables can be used to control the
480 behavior of notmuch.
481 .TP
482 .B NOTMUCH_CONFIG
483 Specifies the location of the notmuch configuration file. Notmuch will
484 use ${HOME}/.notmuch\-config if this variable is not set.
485 .SH SEE ALSO
486 The emacs-based interface to notmuch (available as
487 .B notmuch.el
488 in the Notmuch distribution).
489
490 The notmuch website:
491 .B http://notmuchmail.org
492 .SH CONTACT
493 Feel free to send questions, comments, or kudos to the notmuch mailing
494 list <notmuch@notmuchmail.org> . Subscription is not required before
495 posting, but is available from the notmuchmail.org website.
496
497 Real-time interaction with the Notmuch community is available via IRC
498 (server: irc.freenode.net, channel: #notmuch).