]> git.notmuchmail.org Git - notmuch/blob - notmuch.1
notmuch search: Add --first and --max-threads options for incremental search.
[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 All commands need to know where your mail (and the notmuch database)
44 are stored. This is ${HOME}/mail by default. An alternate location can
45 be specified with the
46 .B NOTMUCH_BASE
47 environment variable.
48
49 The
50 .BR setup " and " new
51 commands are used to add new mail messages to the notmuch database.
52 .RS 4
53 .TP 4
54 .B setup
55
56 Interactively sets up notmuch for first use.
57
58 The setup command will prompt for the directory containing your email
59 archives, and will then proceed to build a database that indexes the
60 mail to allow for fast search of the archive.
61
62 This directory can contain any number of sub-directories and should
63 primarily contain only files with indvidual email messages
64 (eg. maildir or mh archives are perfect). If there are other,
65 non-email files (such as indexes maintained by other email programs)
66 then notmuch will do its best to detect those and ignore them.
67
68 Mail storage that uses mbox format, (where one mbox file contains many
69 messages), will not work with notmuch. If that's how your mail is
70 currently stored, it is recommended you first convert it to maildir
71 format with a utility such as mb2md before running
72 .BR "notmuch setup" .
73
74 Invoking
75 .B notmuch
76 with no command argument will run
77 .B setup
78 if the setup command has not previously been completed.
79
80 .TP
81 .B new
82
83 Find and import any new messages to the database.
84
85 The
86 .B new
87 command scans all sub-directories of the database, adding new messages
88 that are found. Each new message will automatically be tagged with
89 both the
90 .BR inbox and unread
91 tags.
92
93 Note:
94 .B notmuch new
95 will skip any read-only directories, so you can use that to mark
96 directories that will not receive any new mail (and make
97 .B notmuch new
98 faster).
99 .RE
100
101 The
102 .BR search " and "show
103 commands are used to query the email database.
104 .RS 4
105 .TP 4
106 .BR search " <search-term>..."
107
108 Search for messages matching the given search terms, and display as
109 results the threads containing the matched messages.
110
111 The output consists of one line per thread, giving a thread ID, the
112 date of the oldest matched message in the thread, and the subject from
113 that message.
114
115 Currently, in addition to free text (and quoted phrases) which match
116 terms appearing anywhere within an email, the following prefixes can
117 be used to search specific portions of an email, (where <brackets>
118 indicate user-supplied values):
119
120         from:<name-or-address>
121
122         to:<name-or-address>
123
124         subject:<word-or-quoted-phrase>
125
126         tag:<tag>
127
128         id:<message-id>
129
130         thread:<thread-id>
131
132 The from: prefix is used to match the name or address of the sender of
133 an email message.
134
135 The to: prefix is used to match the names or addresses of any
136 recipient of an email message, (whether To, Cc, or Bcc).
137
138 Any term prefixed with subject: will match only text from
139 the subject of an email. Quoted phrases are supported when
140 searching with: subject:\"this is a phrase\".
141
142 Valid tag values include
143 .BR inbox " and " unread
144 by default for new messages added by
145 .B notmuch new
146 as well as any other tag values added manually with
147 .BR "notmuch tag" .
148
149 Message ID values are the literal contents of the Message-ID: header
150 of email messages, but without the '<', '>' delimiters.
151
152 Thread ID values are generated internally by notmuch but can be seen
153 in the first column of output from
154 .B notmuch search
155 for example.
156
157 In addition to individual terms, multiple terms can be
158 combined with Boolean operators (
159 .BR and ", " or ", " not
160 , etc.). each term in the query will be implicitly connected by a
161 logical AND if no explicit operator is provided, (except that terms
162 with a common prefix will be implicitly combined with OR until we get
163 Xapian defect #402 fixed).
164
165 Parentheses can also be used to control the combination of the Boolean
166 operators, but will have to be protected from interpretation by the
167 shell, (such as by putting quotation marks around any parenthesized
168 expression).
169 .TP
170 .BR reply " <search-term>..."
171
172 Constructs a reply template for a set of messages.
173
174 See the documentation of
175 .B search
176 for deatils of the supported syntax of search terms.
177
178 To make replying to email easier,
179 .B notmuch reply
180 takes an existing set of messages and constructs a suitable mail
181 template, taking From: and To: messages and using those for the new
182 To: address; copying Cc: addresses, building a suitable new subject
183 including Re: at the front, adding the old message IDs to the
184 References list and setting the In-Reply-To: field correctly.
185
186 The resulting message template is output to stdout.
187
188 .TP
189 .BR show " <search-term>..."
190
191 Shows all messages matching the search terms.
192
193 See the documentation of
194 .B search
195 for details of the supported syntax of search terms.
196
197 A common use of
198 .B notmuch show
199 is to display a single thread of email messages. For this, use a
200 search term of "thread:<thread-id>" as can be seen in the first
201 column of output from the
202 .B notmuch search
203 command.
204
205 All messages will be displayed in date order. The output format is
206 plain-text, with all text-content MIME parts decoded. Various
207 components in the output,
208 .RB ( message ", " header ", " body ", " attachment ", and MIME " part ),
209 will be delimited by easily-parsed markers. Each marker consists of a
210 Control-L character (ASCII decimal 12), the name of the marker, and
211 then either an opening or closing brace, ('{' or '}'), to either open
212 or close the component.
213 .RE
214
215 The
216 .B tag
217 command is the only command available for manipulating database
218 contents.
219
220 .RS 4
221 .TP 4
222 .BR tag " +<tag>|-<tag> [...] [--] <search-term>..."
223
224 Add/remove tags for all messages matching the search terms.
225
226 The search terms are handled exactly as in
227 .B "notmuch search"
228 so one can use that command first to see what will be modified.
229
230 Tags prefixed by '+' are added while those prefixed by '-' are
231 removed. For each message, tag removal is before tag addition.
232
233 The beginning of <search-terms> is recognized by the first
234 argument that begins with neither '+' nor '-'. Support for
235 an initial search term beginning with '+' or '-' is provided
236 by allowing the user to specify a "--" argument to separate
237 the tags from the search terms.
238
239 Caution: If you run
240 .B "notmuch new"
241 between reading a thread with
242 .B "notmuch show"
243 and removing the "inbox" tag for that thread with
244 .B "notmuch tag"
245 then you create the possibility of moving some messages from that
246 thread out of your inbox without ever reading them. The easiest way to
247 avoid this problem is to not run
248 .B "notmuch new"
249 between reading mail and removing tags.
250 .RE
251
252 The
253 .BR dump " and " restore
254 commands can be used to create a textual dump of email tags for backup
255 purposes, and to restore from that dump
256
257 .RS 4
258 .TP 4
259 .BR dump " [<filename>]"
260
261 Creates a plain-text dump of the tags of each message.
262
263 The output is to the given filename, if any, or to stdout.
264
265 These tags are the only data in the notmuch database that can't be
266 recreated from the messages themselves.  The output of notmuch dump is
267 therefore the only critical thing to backup (and much more friendly to
268 incremental backup than the native database files.)
269 .TP
270 .BR restore " <filename>"
271
272 Restores the tags from the given file (see
273 .BR "notmuch dump" "."
274
275 Note: The dump file format is specifically chosen to be
276 compatible with the format of files produced by sup-dump.
277 So if you've previously been using sup for mail, then the
278 .B "notmuch restore"
279 command provides you a way to import all of your tags (or labels as
280 sup calls them).
281 .SH ENVIRONMENT
282 .B NOTMUCH_BASE
283 Set to the directory which contains the user's mail to be indexed and
284 searched by notmuch. Notmuch will create a directory named
285 .B .notmuch
286 at the toplevel of this directory where it will store its database.
287 .SH SEE ALSO
288 The emacs-based interface to notmuch (available as
289 .B notmuch.el
290 in the Notmuch distribution).
291
292 The notmuch website:
293 .B http://notmuchmail.org