mutt_*mktemp--
[apps/madmutt.git] / contrib / grml-muttng
1 #!/bin/sh
2 # Filename:      grml-muttng
3 # Purpose:       configuration script for mutt-ng
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Die Mär 01 00:26:17 CET 2005 [mika]
8 ################################################################################
9
10 PATH=${PATH:-'/bin/:/sbin/:/usr/local/bin:/usr/bin:/usr/sbin'}
11 PN=`basename "$0"`
12
13 writemuttngrc() {
14 cat > $MUTTRC << EOF
15 # Filename:      .muttngrc
16 # Purpose:       configuration for mailclient muttng, created by 'grml-muttng'
17 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
18 # Bug-Reports:   see http://grml.org/bugs/
19 # License:       This file is licensed under the GPL v2.
20 # Latest change: Son Feb 27 23:14:07 CET 2005 [mika]
21 ################################################################################
22
23 ## some general settings mutt understands:
24
25 # important variables - adjust them if necessary
26   set realname="$REALNAME"
27   set from="$MAILADDR"
28
29 # mailboxes
30   set pop_host="$POP3"
31 $POPDATA
32   mailboxes $IMAP
33 $IMAPDATA
34 # some default options:
35     set allow_8bit           # send data as it is.  no conversion.
36   unset arrow_cursor         #  Show current mail with an inverse bar.
37     set ascii_chars          # set: use ASCII characters to build the thread tree
38     set autoedit             # call editor without prompting for To: and Subject:
39   unset confirmappend        # set: prompt for confirmation on appending mail to folder
40     set confirmcreate        # set: prompt for confirmation on creation of folders
41     set copy                 # Always keep a copy of my mails!
42     set delete=ask-yes       # ask before deleting any messages
43     set edit_headers         # edit all headers lines in the editor
44     set editor=vim           # use Vim as the editor (Vi IMproved www.vim.org)
45     set folder=~/Mail        # directory with all mail folders
46   unset followup_to          # do not generate a Followup-To header
47     set force_name           # set: save outbound mail by username
48     set hidden_host          # do not use a hostname in the address - PROBLEMATIC!
49     set history=100          # number of input lines for prompts to remember
50     set include              # set: include mail as quoted text in replies
51   unset mark_old             # set: make distinction between New mail and Old mail.
52     set mime_forward=ask-yes # ask: attach message - or just quote it?
53   unset move                 # do not move read mails from mailbox to $mbox (was: "set hold")
54     set pager_context=1      # number of lines that overlap on paging
55 #   set pager_index_lines=0  # number of lines to see from the index
56     set pager_stop           # "next_page" won't jump to next message at end of messages
57 #   set print_command="mp|lpr" # pipe message to "mp" for formattting - then on to "lpr"
58   unset prompt_after         # set: gives you a prompt when pager exits
59     set quote_regexp="^>"    # some people just use '>' - *sigh*
60     set read_inc=10          # '10': show count number for every tenth mail
61     set recall=ask-yes       # do not prompt for recalling postponed mails with 'm'
62     set reply_to=ask-yes     # "reply":          set:  Use address in Reply-To?
63     set reverse_alias        # show the name of sender as set with my alias for him
64     set reverse_name         # reply as the user to whom the mail was sent to
65     set save_name            # set: save outbound mail to =username if it exists
66 #   set shell=zsh            # use the zsh for shell commands
67     set sort=threads         # sorting method - I definitely like "threads" best
68     set status_on_top        # set: present the status bar at top, ie before the index
69     set strict_threads       # set: use references: for threading only, ie do not
70                              # thread by subject or in-reply-to
71     set tilde                # show non-existant lines of text with a tilde at begin-of-line
72     set tmpdir="/tmp"        # directory where temporary files are to be placed
73     set to_chars="X+TCF"     # message flags: non-personal,personal,To:,Cc:,From:
74     set use_from             # 'set from=' requires a 'set use_from'!
75     set write_inc=10         # update number after each tenth read mail
76
77 # Options with a long value:
78 #   set alternates=...
79     set attribution="* %n <%a> [%(%y%m%d %H:%M)]:"              # how to cite the author
80     set reply_regexp="^((aw|antw.?|antwort|re|r e|r?f|sv):[ \t]*)*"
81
82 # Format Options
83     set forward_format="(forw) %s"
84     set index_format="%4C %Z %[!%y%m%d] %-17.17F (%3l) %s"
85     set pager_format="%S [%C/%T] %n (%l) %s"
86     set status_format="%v: %f (%s) [%M/%m] [N=%n,*=%t,new=%b]"
87
88 # Show the "text/plain" part *before* the "text/html" part:
89   alternative_order text/plain text/html
90   auto_view text/html
91
92 # KEY BINDINGS
93   bind index zt current-top
94   bind index zz current-middle
95   bind index zb current-bottom
96
97 # HEADER DISPLAY
98   ignore *
99   unignore from: date: subject: to: cc: reply-to:
100   unignore sender:
101   unignore priority: importance:
102   unignore organization organisation
103   unignore mail-followup-to:
104   unignore resent- x-resent
105 # unignore user-agent: x-agent: x-mailer: x-newsreader: x-mailing-list:
106 # unignore x-editor
107 # unignore message-id: newsgroups: posted-to: posted-and-mailed:
108 # unignore x-also-posted-to: x-newsgroups:
109 # unignore delivered-to x-envelope-to:
110 # unignore x-accept-language
111   unhdr_order *
112   hdr_order Sender: From From: Reply-To: Subject: Organization: Date: Message-Id: User-Agent: X-Editor: X-Mailer: X-Newsreader: X-Agent: To: Cc: Newsgroups: X-Resent Followup-To: Mail-Followup-To:
113
114 ## now the mutt-ng specific settings
115
116 # path to header cache file:
117   set header_cache="~/.mutt/headers"
118
119 # sidebar stuff:
120   set sidebar_visible="no"
121   set sidebar_width=25
122   set sidebar_shorten_hierarchy
123   color sidebar_new yellow default
124
125 # keybindings:
126   bind index F flag-message
127   bind pager F flag-message
128
129   macro index z    "c?\t"                            "List mailboxes and switch to selected one"
130   macro index <f2> "<enter-command>set invsidebar_visible<enter>" "Toggle sidebar visibility"
131   macro index \cW  ':push <sidebar-prev-new><enter>' "Jump to previous mailbox with new messages in sidebar"
132   macro index \cE  ':push <sidebar-next-new><enter>' "Jump to next mailbox with new messages in sidebar"
133   macro index \cP  ':push <sidebar-prev><enter>'     "Jump to previous mailbox in sidebar"
134   macro index \cN  ':push <sidebar-next><enter>'     "Jump to next mailbox in sidebar"
135   macro index \cO  ':push <sidebar-open><enter>'     "Open selected mailbox in sidebar"
136 # bind index <space> sidebar-open
137
138 EOF
139 }
140
141 lightcolors() {
142 cat >> $MUTTRC << EOF
143
144 ## color setup
145
146 ## some misc stuff:
147   color normal     black      white
148   color error      red        white
149   color indicator  blue       green
150   color status     white      blue
151   color tree       blue       white
152   color hdrdefault red        white
153   color quoted     blue       white
154   color quoted1    green     white
155   color quoted2    magenta    white
156   color quoted3    cyan       white
157   color tilde      yellow     black
158   color signature  blue       white
159   color search     white      blue   # "search" - matches found with search within the internal pager.
160   color markers    red        black  # "markers" indicate a wrapped line when showing messages with looong lines.
161   color bold       green      black
162   color underline  yellow     black
163
164 ## index-colors:
165   uncolor index *
166
167 # mail from myself *and* to myself (TODO items):
168 #  color index black  brightyellow  '~p ~f prokop'
169
170 # Flagged Messages are important!
171   color index blue white ~N      # New
172   color index magenta default ~T # Tagged
173   color index blue black ~D      # Deleted Mails - use dark color as these are already "dealt with".
174   color index red default ~O     # old messages
175
176 # mail from important people (like myself ;-):
177 # color index white  red '~f prokop'
178
179 # Mails with no obvious addresses (empty To: and Cc: lines)
180    color index cyan white "! ~C ."
181
182 # "DONE mails" ie those I have already replied to.
183    color index blue white  '~Q'
184
185 # non-multipart mails which are tex/html almost always are spam:
186   color index brightmagenta white "~h 'Content-Type: text/html'"
187
188 # Sent to "Undisclosed Recipients":
189   color index white      magenta  '~C Undisclosed.*Recipients'
190
191 # When the Subject indicates a reply (with ":re" but without "Fwd"!)
192 # then there *must* be a reference to the previous message!
193 # So if there is neither an In-Reply-To nor a References line
194 # then it must have been sent with a crappy mailer....
195   color index yellow white "~s re: ! ~s fwd: ! ~x . ! ~h 'in-reply-to: '"
196
197 # No characters in body -> SPAM!
198   color index white white   "! ~b ."
199
200   color index brightred black ~F # Flagged
201
202 ## body-colors:
203
204 # highlight important keywords
205   color body  brightyellow black  "grml"
206
207 # URLs (General Internet addresses):
208   color body yellow red "(finger|ftp|http|news|telnet)://[^ >]*"
209   color body yellow red "<URL:[^ ]*>"
210 # web address without "http":
211   color body yellow red "www\\.[-.a-z0-9]+\\.[a-z][a-z][a-z]?([-_./~a-z0-9]+)?"
212
213 # HTTPS addresses:
214   color body yellow red "https://[^ >]*"
215
216 # FTP addresses:
217   color body yellow red "ftp://[^ ]*"
218
219 # HTTP addresses:
220   color body yellow red "[[:alnum:]][-+.#_[:alnum:]]*@[-+.[:alnum:]]*[[:alnum:]]"
221
222 # File names ("/path/file")
223 #  color body brightgreen white "\\~?\(/[-_.,a-zA-Z0-9{}äöüß]+\)+"
224   color body blue white "\\~?\(/[-_.,a-zA-Z0-9{}äöüß]+\)+"
225
226 # Path names ("/path/")
227   color body brightred   white "\(/[-_.a-zA-Z0-9]+\)+/"
228
229 # Variables  ("$HOME")
230   color body brightmagenta white "\\$[a-zA-Z][-_a-zA-Z]+"
231
232 # Attribution line:
233 # color body red white "^[*] .*:$"
234
235 ## abbreviations and "SCREAMING IN CAPS" in body:
236 # The following includes umlauts - but that's quite clunky.
237 # color body brightyellow  red "[A-ZÄÖÜ][-A-ZÄÖÜ]+[A-ZÄÖÜ][ .!?]?"
238
239 # "+USE_GNU_REGEX":
240 # When you use "+USE_GNU_REGEX" then you can also make use
241 # of "start of word" ("\<") and "end of word" ("\>"):
242   color body red  white    "\\<[-A-Z']{3,}\\>"
243
244 # *Emphasized*, /emphasized/, and _emphasized_ words:
245 # color body brightred      black   "[*/_]+ *[- &[:alnum:]]+ *[*/_]+"
246 # this would catch false positives of the kind _foo* and /bar_
247 # so we should choose matching pairs only:
248   color body brightred  white   "[*][-[:alnum:]]+[*]"
249   color body brightred  white     "/[-[:alnum:]]+/"
250   color body brightred  white     "_[-[:alnum:]]+_"
251
252 # Smileys:  :-)  ;-)  :-|  :-/  :-(
253   color body brightyellow white    "[;:]-[)/(|]"
254 # Grinning:  "grin" ([g]) and "big grin" ([bg]):
255   color body blue   red      "<[Gg]>"
256   color body blue   red      "<[Bb][Gg]>"
257
258 # Border Lines of length three or more.
259 # (Several Newsletters use border lines..)
260   color body green  white    "[-_=+~/\*]{3,}"
261
262 # Extensive use of exclamation and question marks:
263 # "!!!"  "???"
264   color body red    white    "[!?]{3,}"
265
266 # Percentages ("Save xx.x %!")
267   color body brightgreen white "[.0-9]+ ?%"
268
269 # Copyright (C) and Registered Trademark (r)
270   color body red white "[(][cr][)]"
271   color body red white "\\(c\\)"
272
273 # Year Numbers 1980-2002
274   color body blue white "19[89][0-9]"
275   color body blue white "200[012]"
276
277 # Phone Numbers:
278   color body blue white "1-[0-9]{3}[- ][-0-9]+ +ext.? [0-9]+"
279   color body blue white \
280 "(tele)?(cell|fax|fon|phone|tel)[.: ]+[+]?[- 0-9/()]{4,}[0-9]"
281
282 # RTFM!
283 # " man word"
284   color body white red "^ +[$]? *man \\w+"
285
286 # Lists
287 # bulleted list:
288 # * one
289 # * two
290 # * three
291 # dashed list:
292 # - one
293 # - two
294 # - three
295 # color body red          black "^ *[-*] +"
296 # this pattern yields many false positives as it
297 # spans lines for which there is no syntax language.
298 # this is easier with Vim's syntax coloring.
299   color body red white "^ *[-*] +"
300
301 # special IP host addresses:
302 # 192.x.x.x
303   color body white blue  "129.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"
304   color body white blue  "193.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}"
305
306 # HTML tags
307   color body yellow       black "</?\w+>"
308
309 # Emphasis by interspersed spaces
310 # Example: E M P H A S I S
311   color body red white '\<\w( +\w\>)+'
312
313 # verbatim marks (#v+ till #v-)
314   color body yellow red  ^\#v[-+]
315
316   color attachment black white
317 EOF
318 }
319
320 dialog --stdout --title "$PN" --msgbox "Welcome to $PN!
321
322 This script will create a simple base
323 configuration for the mailclient mutt-ng.
324
325 Report bugs, send wishes and feedback to the grml team:
326 http://www.grml.org/ - contact (at) grml.org
327 " 13 65
328
329 GETREALNAME=$(dialog --stdout --title "$PN" --inputbox "Your real name (eg 'John GRML User'):" 0 56) || exit 0
330 REALNAME=${GETREALNAME%/*}
331
332 GETMAILADDR=$(dialog --stdout --title "$PN" --inputbox "Your main mail address (eg 'joedoe@grml.org'):" 0 56) || exit 0
333 MAILADDR=${GETMAILADDR%/*}
334
335 askpop(){
336   GETPOPUSER=$(dialog --stdout --title "$PN" --inputbox "Enter username for POP3 account" 0 0)
337   POPUSER=${GETPOPUSER}
338
339   GETPOPPWD=$(dialog --stdout --title "$PN" --passwordbox "Enter password for POP3 account (typing hidden)" 0 0)
340   POPPWD=${GETPOPPWD}
341 }
342
343 ASKPOP=$(dialog --stdout --title "$PN" --yesno "Configure POP3?" 0 0)
344 retval=$?
345
346 case $retval in
347   0) 
348      GETPOP3=$(dialog --stdout --title "$PN" --inputbox  "Your POP3 account (pop[s]://[user]@hostname[:port]):" 0 56 "pop://") || exit 0
349      POP3=${GETPOP3}
350      askpop && \
351 POPDATA="  set pop_user=\"$POPUSER\"
352   set pop_pass=\"$POPPWD\"
353 "
354      ;;
355 esac
356
357 askimap(){
358   GETIMAPUSER=$(dialog --stdout --title "$PN" --inputbox "Enter username for IMAP account" 0 0)
359   IMAPUSER=${GETIMAPUSER}
360
361   GETIMAPPWD=$(dialog --stdout --title "$PN" --passwordbox "Enter password for IMAP account (typing hidden)" 0 0)
362   IMAPPWD=${GETIMAPPWD}
363 }
364
365 ASKIMAP=$(dialog --stdout --title "$PN" --yesno "Configure IMAP?" 0 0)
366 retval=$?
367
368 case $retval in
369   0) 
370      GETIMAP=$(dialog --stdout --title "$PN" --inputbox  "Your IMAP account (imap[s]://[user@]hostname[:port]/mailbox):" 0 65 "imap://") || exit 0
371      IMAP=${GETIMAP}
372      askimap && \
373 IMAPDATA="  set imap_user=\"$IMAPUSER\"
374   set imap_pass=\"$IMAPPWD\"
375 "
376      ;;
377 esac
378
379 GETCOLOR=$(dialog --stdout --title "$PN" \
380         --radiolist "Which color setup do you want to use?" 10 65 2 \
381           dark   "dark color setup (default)" on \
382           light  "light color setup" off)
383 retval=$?
384
385 case $retval in
386   0) COLOR=$GETCOLOR ;;
387   *) exit 1 ;;
388 esac
389
390 writecolors() {
391   if [ "$COLOR" == 'light' ] ; then
392     lightcolors
393   fi
394 }
395
396 GETMUTTRC=$(dialog --stdout --title "$PN" --inputbox "Choose a filename for this configuration:" 0 56 "$HOME/.muttngrc") || exit 0
397 MUTTRC=${GETMUTTRC}
398
399 WRITEMUTTRC=$(dialog --stdout --title "$PN" --yesno "Write $MUTTRC?" 5 65)
400 retval=$?
401
402 case $retval in
403   0) 
404     if [ -f "$MUTTRC" ] ; then
405       dialog --stdout --title "$PN" --yesno "$MUTTRC exists. Overwrite?" 5 65
406       retval=$?
407       case $retval in
408         0) 
409           writemuttngrc && writecolors && \
410           dialog --stdout --title "$PN" --msgbox "Writing $MUTTRC was successful." 7 65 || \
411           dialog --stdout --title "$PN" --msgbox "Error $?: writing $MUTTRC failed." 7 65
412           ;;
413 #        *) exit 1 ;;
414       esac
415     else
416        writemuttngrc && writecolors && \
417        dialog --stdout --title "$PN" --msgbox "Writing $MUTTRC was successfull." 7 65 || \
418        dialog --stdout --title "$PN" --msgbox "Error $?: writing $MUTTRC failed." 7 65
419     fi
420     ;;
421 #  *) exit 1 ;;
422 esac
423
424 dialog --stdout --title "$PN" --msgbox "Thanks for using $PN!
425
426 More information on mutt-ng:
427
428 Manuals: man 1 muttng
429          man 5 muttngrc
430
431 Webpages:
432 http://mutt-ng.berlios.de/
433 http://mutt-ng.supersized.org/
434 http://www.strcat.de/muttng/pmwiki.php
435
436 #######################################################
437
438 Report bugs, send wishes and feedback to the grml team:
439 http://www.grml.org/ - contact (at) grml.org
440 " 24 65
441
442 ## END OF FILE #################################################################