]> git.notmuchmail.org Git - notmuch/blob - notmuch.1
853b5eafab31cac83959e074713174f528d6475a
[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 ", " show " and " count
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
154 .RS 4
155 .TP 4
156 .B \-\-output=(summary|threads|messages|files|tags)
157
158 .RS 4
159 .TP 4
160 .B summary
161
162 Output a summary of each thread with any message matching the search
163 terms. The summary includes the thread ID, date, the number of
164 messages in the thread (both the number matched and the total number),
165 the authors of the thread and the subject.
166 .RE
167 .RS 4
168 .TP 4
169 .B threads
170
171 Output the thread IDs of all threads with any message matching the
172 search terms, either one per line (\-\-format=text) or as a JSON array
173 (\-\-format=json).
174 .RE
175 .RS 4
176 .TP 4
177 .B messages
178
179 Output the message IDs of all messages matching the search terms,
180 either one per line (\-\-format=text) or as a JSON array
181 (\-\-format=json).
182 .RE
183 .RS 4
184 .TP 4
185 .B files
186
187 Output the filenames of all messages matching the search terms, either
188 one per line (\-\-format=text) or as a JSON array (\-\-format=json).
189 .RE
190 .RS 4
191 .TP 4
192 .B tags
193
194 Output all tags that appear on any message matching the search terms,
195 either one per line (\-\-format=text) or as a JSON array
196 (\-\-format=json).
197 .RE
198 .RE
199
200 .RS 4
201 .TP 4
202 .BR \-\-sort= ( newest\-first | oldest\-first )
203
204 This option can be used to present results in either chronological order
205 .RB ( oldest\-first )
206 or reverse chronological order
207 .RB ( newest\-first ).
208
209 Note: The thread order will be distinct between these two options
210 (beyond being simply reversed). When sorting by
211 .B oldest\-first
212 the threads will be sorted by the oldest message in each thread, but
213 when sorting by
214 .B newest\-first
215 the threads will be sorted by the newest message in each thread.
216
217 .RE
218 .RS 4
219 By default, results will be displayed in reverse chronological order,
220 (that is, the newest results will be displayed first).
221
222 See the
223 .B "SEARCH SYNTAX"
224 section below for details of the supported syntax for <search-terms>.
225 .RE
226 .TP
227 .BR show " [options...] <search-term>..."
228
229 Shows all messages matching the search terms.
230
231 The messages will be grouped and sorted based on the threading (all
232 replies to a particular message will appear immediately after that
233 message in date order). The output is not indented by default, but
234 depth tags are printed so that proper indentation can be performed by
235 a post-processor (such as the emacs interface to notmuch).
236
237 Supported options for
238 .B show
239 include
240 .RS 4
241 .TP 4
242 .B \-\-entire\-thread
243
244 By default only those messages that match the search terms will be
245 displayed. With this option, all messages in the same thread as any
246 matched message will be displayed.
247 .RE
248
249 .RS 4
250 .TP 4
251 .B \-\-format=(text|json|mbox)
252
253 .RS 4
254 .TP 4
255 .B text
256
257 The default plain-text format has all text-content MIME parts
258 decoded. Various components in the output,
259 .RB ( message ", " header ", " body ", " attachment ", and MIME " part ),
260 will be delimited by easily-parsed markers. Each marker consists of a
261 Control-L character (ASCII decimal 12), the name of the marker, and
262 then either an opening or closing brace, ('{' or '}'), to either open
263 or close the component.
264 .RE
265 .RS 4
266 .TP 4
267 .B json
268
269 The output is formatted with Javascript Object Notation (JSON). This
270 format is more robust than the text format for automated
271 processing. JSON output always includes all messages in a matching
272 thread; in effect
273 .B \-\-format=json
274 implies
275 .B \-\-entire\-thread
276
277 .RE
278 .RS 4
279 .TP 4
280 .B mbox
281
282 All matching messages are output in the traditional, Unix mbox format
283 with each message being prefixed by a line beginning with "From " and
284 a blank line separating each message. Lines in the message content
285 beginning with "From " (preceded by zero or more '>' characters) have
286 an additional '>' character added. This reversible escaping
287 is termed "mboxrd" format and described in detail here:
288 http://homepage.ntlworld.com/jonathan.deboynepollard/FGA/mail-mbox-formats.html
289 .RE
290 A common use of
291 .B notmuch show
292 is to display a single thread of email messages. For this, use a
293 search term of "thread:<thread-id>" as can be seen in the first
294 column of output from the
295 .B notmuch search
296 command.
297
298 See the
299 .B "SEARCH SYNTAX"
300 section below for details of the supported syntax for <search-terms>.
301 .RE
302 .TP
303 .BR cat  " <search-term>..."
304
305 Output raw content of a single message matched by the search term.
306 .TP
307 .BR count " <search-term>..."
308
309 Count messages matching the search terms.
310
311 The number of matching messages is output to stdout.
312
313 With no search terms, a count of all messages in the database will be
314 displayed.
315 .RE
316 .RE
317
318 The
319 .B reply
320 command is useful for preparing a template for an email reply.
321 .RS 4
322 .TP 4
323 .BR reply " [options...] <search-term>..."
324
325 Constructs a reply template for a set of messages.
326
327 To make replying to email easier,
328 .B notmuch reply
329 takes an existing set of messages and constructs a suitable mail
330 template. The Reply-to header (if any, otherwise From:) is used for
331 the To: address. Vales from the To: and Cc: headers are copied, but
332 not including any of the current user's email addresses (as configured
333 in primary_mail or other_email in the .notmuch\-config file) in the
334 recipient list
335
336 It also builds a suitable new subject, including Re: at the front (if
337 not already present), and adding the message IDs of the messages being
338 replied to to the References list and setting the In\-Reply\-To: field
339 correctly.
340
341 Finally, the original contents of the emails are quoted by prefixing
342 each line with '> ' and included in the body.
343
344 The resulting message template is output to stdout.
345
346 Supported options for
347 .B reply
348 include
349 .RS
350 .TP 4
351 .BR \-\-format= ( default | headers\-only )
352 .RS
353 .TP 4
354 .BR default
355 Includes subject and quoted message body.
356 .TP
357 .BR headers\-only
358 Only produces In\-Reply\-To, References, To, Cc, and Bcc headers.
359 .RE
360
361 See the
362 .B "SEARCH SYNTAX"
363 section below for details of the supported syntax for <search-terms>.
364
365 Note: It is most common to use
366 .B "notmuch reply"
367 with a search string matching a single message, (such as
368 id:<message-id>), but it can be useful to reply to several messages at
369 once. For example, when a series of patches are sent in a single
370 thread, replying to the entire thread allows for the reply to comment
371 on issue found in multiple patches.
372 .RE
373 .RE
374
375 The
376 .B tag
377 command is the only command available for manipulating database
378 contents.
379
380 .RS 4
381 .TP 4
382 .BR tag " +<tag>|\-<tag> [...] [\-\-] <search-term>..."
383
384 Add/remove tags for all messages matching the search terms.
385
386 Tags prefixed by '+' are added while those prefixed by '\-' are
387 removed. For each message, tag removal is performed before tag
388 addition.
389
390 The beginning of <search-terms> is recognized by the first
391 argument that begins with neither '+' nor '\-'. Support for
392 an initial search term beginning with '+' or '\-' is provided
393 by allowing the user to specify a "\-\-" argument to separate
394 the tags from the search terms.
395
396 See the
397 .B "SEARCH SYNTAX"
398 section below for details of the supported syntax for <search-terms>.
399 .RE
400
401 The
402 .BR dump " and " restore
403 commands can be used to create a textual dump of email tags for backup
404 purposes, and to restore from that dump
405
406 .RS 4
407 .TP 4
408 .BR dump " [<filename>]"
409
410 Creates a plain-text dump of the tags of each message.
411
412 The output is to the given filename, if any, or to stdout.
413
414 These tags are the only data in the notmuch database that can't be
415 recreated from the messages themselves.  The output of notmuch dump is
416 therefore the only critical thing to backup (and much more friendly to
417 incremental backup than the native database files.)
418 .TP
419 .BR restore " <filename>"
420
421 Restores the tags from the given file (see
422 .BR "notmuch dump" "."
423
424 Note: The dump file format is specifically chosen to be
425 compatible with the format of files produced by sup-dump.
426 So if you've previously been using sup for mail, then the
427 .B "notmuch restore"
428 command provides you a way to import all of your tags (or labels as
429 sup calls them).
430 .RE
431
432 The
433 .B part
434 command can used to output a single part of a multi-part MIME message.
435
436 .RS 4
437 .TP 4
438 .BR part " \-\-part=<part-number> <search-term>..."
439
440 Output a single MIME part of a message.
441
442 A single decoded MIME part, with no encoding or framing, is output to
443 stdout. The search terms must match only a single message, otherwise
444 this command will fail.
445
446 The part number should match the part "id" field output by the
447 "\-\-format=json" option of "notmuch show". If the message specified by
448 the search terms does not include a part with the specified "id" there
449 will be no output.
450
451 See the
452 .B "SEARCH SYNTAX"
453 section below for details of the supported syntax for <search-terms>.
454 .RE
455
456 The
457 .B config
458 command can be used to get or set settings int the notmuch
459 configuration file.
460
461 .RS 4
462 .TP 4
463 .BR "config get " <section> . <item>
464
465 The value of the specified configuration item is printed to stdout. If
466 the item has multiple values, each value is separated by a newline
467 character.
468
469 Available configuration items include at least
470
471         database.path
472
473         user.name
474
475         user.primary_email
476
477         user.other_email
478
479         new.tags
480 .RE
481
482 .RS 4
483 .TP 4
484 .BR "config set " <section> . "<item> [values ...]"
485
486 The specified configuration item is set to the given value.  To
487 specify a multiple-value item, provide each value as a separate
488 command-line argument.
489
490 If no values are provided, the specified configuration item will be
491 removed from the configuration file.
492 .RE
493
494 .SH SEARCH SYNTAX
495 Several notmuch commands accept a common syntax for search terms.
496
497 The search terms can consist of free-form text (and quoted phrases)
498 which will match all messages that contain all of the given
499 terms/phrases in the body, the subject, or any of the sender or
500 recipient headers.
501
502 As a special case, a search string consisting of exactly a single
503 asterisk ("*") will match all messages.
504
505 In addition to free text, the following prefixes can be used to force
506 terms to match against specific portions of an email, (where
507 <brackets> indicate user-supplied values):
508
509         from:<name-or-address>
510
511         to:<name-or-address>
512
513         subject:<word-or-quoted-phrase>
514
515         attachment:<word>
516
517         tag:<tag> (or is:<tag>)
518
519         id:<message-id>
520
521         thread:<thread-id>
522
523 The
524 .B from:
525 prefix is used to match the name or address of the sender of an email
526 message.
527
528 The
529 .B to:
530 prefix is used to match the names or addresses of any recipient of an
531 email message, (whether To, Cc, or Bcc).
532
533 Any term prefixed with
534 .B subject:
535 will match only text from the subject of an email. Searching for a
536 phrase in the subject is supported by including quotation marks around
537 the phrase, immediately following
538 .BR subject: .
539
540 The
541 .B attachment:
542 prefix can be used to search for specific filenames (or extensions) of
543 attachments to email messages.
544
545 For
546 .BR tag: " and " is:
547 valid tag values include
548 .BR inbox " and " unread
549 by default for new messages added by
550 .B notmuch new
551 as well as any other tag values added manually with
552 .BR "notmuch tag" .
553
554 For
555 .BR id: ,
556 message ID values are the literal contents of the Message\-ID: header
557 of email messages, but without the '<', '>' delimiters.
558
559 The
560 .B thread:
561 prefix can be used with the thread ID values that are generated
562 internally by notmuch (and do not appear in email messages). These
563 thread ID values can be seen in the first column of output from
564 .B "notmuch search"
565
566 In addition to individual terms, multiple terms can be
567 combined with Boolean operators (
568 .BR and ", " or ", " not
569 , etc.). Each term in the query will be implicitly connected by a
570 logical AND if no explicit operator is provided, (except that terms
571 with a common prefix will be implicitly combined with OR until we get
572 Xapian defect #402 fixed).
573
574 Parentheses can also be used to control the combination of the Boolean
575 operators, but will have to be protected from interpretation by the
576 shell, (such as by putting quotation marks around any parenthesized
577 expression).
578
579 Finally, results can be restricted to only messages within a
580 particular time range, (based on the Date: header) with a syntax of:
581
582         <intial-timestamp>..<final-timestamp>
583
584 Each timestamp is a number representing the number of seconds since
585 1970\-01\-01 00:00:00 UTC. This is not the most convenient means of
586 expressing date ranges, but until notmuch is fixed to accept a more
587 convenient form, one can use the date program to construct
588 timestamps. For example, with the bash shell the folowing syntax would
589 specify a date range to return messages from 2009\-10\-01 until the
590 current time:
591
592         $(date +%s \-d 2009\-10\-01)..$(date +%s)
593 .SH ENVIRONMENT
594 The following environment variables can be used to control the
595 behavior of notmuch.
596 .TP
597 .B NOTMUCH_CONFIG
598 Specifies the location of the notmuch configuration file. Notmuch will
599 use ${HOME}/.notmuch\-config if this variable is not set.
600 .SH SEE ALSO
601 The emacs-based interface to notmuch (available as
602 .B notmuch.el
603 in the Notmuch distribution).
604
605 The notmuch website:
606 .B http://notmuchmail.org
607 .SH CONTACT
608 Feel free to send questions, comments, or kudos to the notmuch mailing
609 list <notmuch@notmuchmail.org> . Subscription is not required before
610 posting, but is available from the notmuchmail.org website.
611
612 Real-time interaction with the Notmuch community is available via IRC
613 (server: irc.freenode.net, channel: #notmuch).