https://wiki.archlinux.org/api.php?action=feedcontributions&user=Paris3200&feedformat=atomArchWiki - User contributions [en]2024-03-29T11:54:07ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Mutt&diff=367428Mutt2015-03-27T19:30:14Z<p>Paris3200: /* Goobook */</p>
<hr />
<div>[[Category:Email clients]]<br />
[[es:Mutt]]<br />
[[it:Mutt]]<br />
[[zh-CN:Mutt]]<br />
[[zh-TW:Mutt]]<br />
{{Related articles start}}<br />
{{Related|fdm}}<br />
{{Related|msmtp}}<br />
{{Related|offlineimap}}<br />
{{Related|isync}}<br />
{{Related articles end}}<br />
'''Mutt''' is a text-based mail client renowned for its powerful features. Though over a decade old, Mutt remains the mail client of choice for a great number of power-users. Unfortunately, a default Mutt install is plagued by complex keybindings along with a daunting amount of documentation. This guide will help the average user get Mutt up and running, and begin customizing it to their particular needs.<br />
<br />
==Overview==<br />
Mutt focuses primarily on being a Mail User Agent (MUA), and was originally written to view mail. Later implementations (added for retrieval, sending, and filtering mail) are simplistic compared to other mail applications and, as such, users may wish to use external applications to extend Mutt's capabilities. <br />
<br />
Nevertheless, the Arch Linux {{Pkg|mutt}} package is compiled with IMAP, POP3 and SMTP support, removing the necessity for external applications.<br />
<br />
This article covers using both native IMAP sending and retrieval, and a setup depending on [[OfflineIMAP]] or [[getmail]] (POP3) to retrieve mail, [[procmail]] to filter it in the case of POP3, and [[msmtp]] to send it.<br />
<br />
==Installing==<br />
[[pacman|Install]] {{Pkg|mutt}}, available in the [[official repositories]]. <br />
<br />
Optionally install external helper applications for an IMAP setup, such as [[isync]], [[OfflineIMAP]], or [[msmtp]].<br />
<br />
Or (if using POP3) {{Pkg|getmail}}, {{Pkg|fetchmail}} or {{Pkg|fdm}} and {{Pkg|procmail}}.<br />
<br />
{{Note|<br />
*If you just need the authentication methods LOGIN and PLAIN, these are satisfied with the dependency {{Pkg|libsasl}}<br />
*If you want to (or have to) use CRAM-MD5, GSSAPI or DIGEST-MD5, install the package {{Pkg|cyrus-sasl-gssapi}}<br />
*If you are using Gmail as your SMTP server, you may need to install the package {{Pkg|cyrus-sasl}}<br />
}}<br />
<br />
==Configuring==<br />
This section covers [[#IMAP]], [[#POP3]], [[#Maildir]] and [[#SMTP]] configuration.<br />
<br />
Note that Mutt will recognize by default two locations for its configuration file; {{ic|~/.muttrc}} and {{ic|~/.mutt/muttrc}}. Either location will work. In case you decide to put the initialization file somewhere else, use {{ic|$ mutt -F /path/to/.muttrc}}.<br />
You should also know some prerequisite for Mutt configuration. Its syntax is very close to the Bourne Shell. For example, you can get the content of another config file:<br />
source /path/to/other/config/file<br />
You can use variables and assign the result of shell commands to them.<br />
set editor=`echo \$EDITOR`<br />
Here the {{ic|$}} gets escaped so that it does not get substituted by Mutt before being passed to the shell.<br />
Also note the use of the backquotes, as bash syntax {{ic|$(...)}} does not work.<br />
Mutt has a lot of predefined variables, but you can also set your own. User variable '''must begin with "my"!'''<br />
set my_name = "John Doe"<br />
<br />
===IMAP===<br />
<br />
====Native IMAP support====<br />
The pacman version of Mutt is compiled with IMAP support. At the very least you need to have 4 lines in your muttrc file to be able to access your mail.<br />
<br />
=====imap_user=====<br />
set imap_user=USERNAME<br />
<br />
{{Tip|Continuing with the previous example, remember that Gmail requires your full email address (this is not standard): {{bc|1=set imap_user=your.username@gmail.com}}}}<br />
<br />
=====imap_pass=====<br />
If unset, the password will be prompted for.<br />
set imap_pass=SECRET<br />
<br />
{{Tip|If you have enabled two-factor authentication in Gmail and you have added an application specific password for Mutt, you will want to use that password here rather than your regular Gmail password.}}<br />
<br />
=====folder=====<br />
Instead of a local directory which contains all your mail (and directories), use your server (and the highest folder in the hierarchy, if needed).<br />
set folder=imap[s]://imap.server.domain[:port]/[folder/]<br />
<br />
You do not have to use a folder, but it might be convenient if you have all your other folders inside your INBOX, for example. Whatever you set here as your folder can be accessed later in Mutt with just an equal sign (=) or a plus sign (+). Example:<br />
set folder=imaps://imap.gmail.com/<br />
<br />
It should be noted that for several accounts, it is best practice to use different folders -- e.g. for ''account-hook''. If you have several Gmail account, use<br />
set folder=imaps://username@imap.gmail.com/<br />
instead, where your account is ''username@gmail.com''. This way it will be possible to distinguish the different folders. Otherwise it would lead to authentication errors.<br />
<br />
=====spoolfile=====<br />
The spoolfile is the folder where your (unfiltered) e-mail arrives. Most e-mail services conventionally names it ''INBOX''. You can now use '=' or '+' as a substitution for the full {{ic|folder}} path that was configured above. For example:<br />
set spoolfile=+INBOX<br />
<br />
=====mailboxes=====<br />
Any imap folders that should be checked regularly for new mail should be listed here:<br />
mailboxes =INBOX =family<br />
mailboxes imaps://imap.gmail.com/INBOX imaps://imap.gmail.com/family<br />
<br />
Alternatively, check for all subscribed IMAP folders (as if all were added with a {{Ic|mailboxes}} line):<br />
set imap_check_subscribed<br />
<br />
These two versions are equivalent if you want to subscribe to all folders. So the second method is much more convenient, but the first one gives you more flexibility. Also, newer Mutt versions are configured by default to include a macro bound to the 'y' key which will allow you to change to any of the folders listed under mailboxes.<br />
<br />
If you do not set this variable, the ''spoolfile'' will be used by default.<br />
This variable is also important for the [[#Mutt-Sidebar|sidebar]].<br />
<br />
=====Summary=====<br />
Using these options, you will be able to start Mutt, enter your IMAP password, and start reading your mail. Here is a muttrc snippet (for Gmail) with some other lines you might consider adding for better IMAP support.<br />
{{bc|1=<br />
set folder = imaps://imap.gmail.com/<br />
set imap_user = your.username@gmail.com<br />
set imap_pass = your-imap-password<br />
set spoolfile = +INBOX<br />
mailboxes = +INBOX<br />
<br />
# Store message headers locally to speed things up.<br />
# If hcache is a folder, Mutt will create sub cache folders for each account which may speeds things up even more.<br />
set header_cache = ~/.cache/mutt<br />
<br />
# Store messages locally to speed things up, like searching message bodies.<br />
# Can be the same folder as header_cache.<br />
# This will cost important disk usage according to your e-mail amount.<br />
set message_cachedir = "~/.cache/mutt"<br />
<br />
# Specify where to save and/or look for postponed messages.<br />
set postponed = +[Gmail]/Drafts<br />
<br />
# Allow Mutt to open new imap connection automatically.<br />
unset imap_passive<br />
<br />
# Keep IMAP connection alive by polling intermittently (time in seconds).<br />
set imap_keepalive = 300<br />
<br />
# How often to check for new mail (time in seconds).<br />
set mail_check = 120<br />
}}<br />
<br />
====External IMAP support====<br />
While IMAP support is built into Mutt, it does not download mail for offline use. It is possible to use an external application such as [[OfflineIMAP]] or [[isync]] to download your emails to a local folder which can then be processed by Mutt.<br />
<br />
Consider using applications such as {{pkg|spamassassin}} or {{AUR|imapfilter}} to sort mail.<br />
<br />
===POP3===<br />
One popular option is to use [[getmail]] for retrieving and [[procmail]] for filtering the mail.<br />
<br />
===Maildir===<br />
Maildir is a generic and standardized format. Almost every MUA is able to handle Maildirs and Mutt's support is excellent. There are just a few simple things that you need to do to get Mutt to use them. Open your muttrc and add the following lines:<br />
{{bc|1=<br />
set mbox_type=Maildir<br />
set folder=$HOME/mail<br />
set spoolfile=+/<br />
set header_cache=~/.cache/mutt<br />
}}<br />
<br />
This is a minimal Configuration that enables you to access your Maildir and checks for new local Mails in INBOX. This configuration also caches the headers of the eMails to speed up directory-listings. It might not be enabled in your build (but it sure is in the Arch-Package). Note that this does not affect OfflineIMAP in any way. It always syncs the all directories on a Server. {{ic|spoolfile}} tells Mutt which local directories to poll for new Mail. You might want to add more Spoolfiles (for example the Directories of Mailing-Lists) and maybe other things. But this is subject to the Mutt manual and beyond the scope of this document.<br />
<br />
===SMTP===<br />
Whether you use POP or IMAP to receive mail you will probably still send mail using SMTP.<br />
<br />
==== Folders ====<br />
<br />
There is basically only one important folder here: the one where all your sent e-mails will be saved.<br />
set record = +Sent<br />
<br />
Gmail saves automatically sent e-mail to {{ic|+[Gmail]/Sent}}, so we do not want<br />
duplicates.<br />
unset record<br />
<br />
====Native SMTP support====<br />
The official {{Pkg|mutt}} is also compiled with SMTP support.<br />
<br />
For example:<br />
{{bc|1=<br />
set my_pass='mysecretpass'<br />
set my_user=myname<br />
<br />
set realname = 'Your Real Name'<br />
set from = your-email-address<br />
set use_from = yes<br />
<br />
set smtp_url=smtps://$my_user:$my_pass@smtp.domain.tld<br />
set ssl_force_tls = yes<br />
}}<br />
<br />
Note that if your SMTP credentials are the same as your IMAP credentials, then you can use those variables:<br />
<br />
{{bc|1=<br />
set smtp_url=smtps://$imap_user:$imap_pass@smtp.domain.tld<br />
}}<br />
<br />
You may need to tweak the security parameters. If you get an error like<br />
{{ic|SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol}},<br />
then your server probably uses the SMTP instead of SMTPS.<br />
<br />
{{bc|1=<br />
set smtp_url=smtp://$imap_user:$imap_pass@smtp.domain.tld<br />
}}<br />
<br />
There are other variables that you may need to set. For example for use of STARTTLS:<br />
{{bc|1=<br />
set ssl_starttls = yes<br />
}}<br />
<br />
See {{ic|man 5 muttrc}} for more information.<br />
<br />
====External SMTP support====<br />
<br />
An external SMTP agent such as [[msmtp]], [[SSMTP]] or {{Pkg|opensmtpd}} can also be used.<br />
<br />
The {{ic|sendmail}} variable in your {{ic|muttrc}} determines the program and arguments used to deliver mail in mutt. Any additional arguments must be interpreted by the program as recipient addresses.<br />
<br />
For example, if using [[msmtp]]:<br />
<br />
{{hc|muttrc|2=<br />
set realname='Disgruntled Kangaroo'<br />
<br />
set sendmail="/usr/bin/msmtp"<br />
<br />
set edit_headers=yes<br />
set folder=~/mail<br />
set mbox=+mbox<br />
set spoolfile=+inbox<br />
set record=+sent<br />
set postponed=+drafts<br />
set mbox_type=Maildir<br />
<br />
mailboxes +inbox +lovey-dovey +happy-kangaroos<br />
}}<br />
<br />
====Sending mails from Mutt====<br />
Now, startup {{Ic|mutt}}:<br />
<br />
You should see all the mail in {{ic|~/mail/inbox}}. Press {{ic|m}} to compose mail; it will use the editor defined by your {{Ic|EDITOR}} environment variable. If this variable is not set, you can fix it before starting Mutt:<br />
$ export EDITOR=your-favorite-editor<br />
$ mutt<br />
<br />
You should store the EDITOR value into your shell resource configuration file (such as [[bashrc]]).<br />
You can also set the editor from Mutt's configuration file:<br />
{{hc|.muttrc|2=<br />
set editor=your-favorite-editor<br />
}}<br />
<br />
For testing purposes, address the letter to yourself. After you have written the letter, save and exit the editor. You will return to Mutt, which will now show information about your e-mail. Press {{ic|y}} to send it.<br />
<br />
===Multiple accounts===<br />
<br />
Now you should have a working configuration for one account at least. You might wonder how to use several accounts, since we put everything into a single file.<br />
<br />
Well all you need is to write account-specific parameters to their respective files and source them. All the IMAP/POP3/SMTP config for each account should go to its respective folder.<br />
{{Warning|When one account is setting a variable that is not specified for other accounts, you '''must unset''' it for them, otherwise configuration will overlap and you will most certainly experience unexpected behaviour.}}<br />
<br />
Mutt can handle this thanks to one of its most powerful features: hooks.<br />
Basically a hook is a command that gets executed before a specific action.<br />
There are several hooks available. For multiple accounts, you must use account-hooks ''and'' folder-hooks.<br />
* Folder-hooks will run a command before switching folders. This is mostly useful to set the appropriate SMTP parameters when you are in a specific folder. For instance when you are in your work mailbox and you send a e-mail, it will automatically use your work account as sender.<br />
* Account-hooks will run a command everytime Mutt calls a function related to an account, like IMAP syncing. It does not require you to switch to any folder.<br />
<br />
Hooks take two parameters:<br />
account-hook [!]regex command<br />
folder-hook [!]regex command<br />
The regex is the folder to be matched (or not if preceded by the !).<br />
The command tells what to do.<br />
<br />
Let us give a full example:<br />
<br />
{{hc|.muttrc|<nowiki><br />
## General options<br />
set header_cache = "~/.cache/mutt"<br />
set imap_check_subscribed<br />
set imap_keepalive = 300<br />
unset imap_passive<br />
set mail_check = 60<br />
set mbox_type=Maildir<br />
<br />
## ACCOUNT1<br />
source "~/.mutt/work"<br />
# Here we use the $folder variable that has just been set in the sourced file.<br />
# We must set it right now otherwise the 'folder' variable will change in the next sourced file.<br />
folder-hook $folder 'source ~/.mutt/work'<br />
<br />
## ACCOUNT2<br />
source "~/.mutt/personal"<br />
folder-hook *user@gmail.com/ 'source ~/.mutt/personal'<br />
folder-hook *user@gmail.com/Family 'set realname="Bob"'<br />
</nowiki>}}<br />
<br />
{{hc|.mutt/work|<nowiki><br />
## Receive options.<br />
set imap_user=user@gmail.com<br />
set imap_pass=****<br />
set folder = imaps://user@imap.gmail.com/<br />
set spoolfile = +INBOX<br />
set postponed = +Drafts<br />
set record = +Sent<br />
<br />
## Send options.<br />
set smtp_url=smtps://user:****@smtp.gmail.com<br />
set realname='User X'<br />
set from=user@gmail.com<br />
set hostname="gmail.com"<br />
set signature="John Doe"<br />
# Connection options<br />
set ssl_force_tls = yes<br />
unset ssl_starttls<br />
<br />
## Hook -- IMPORTANT!<br />
account-hook $folder "set imap_user=user@gmail.com imap_pass=****"<br />
</nowiki>}}<br />
<br />
Finally {{ic|.mutt/personal}} should be similar to {{ic|.mutt/work}}.<br />
<br />
Now all your accounts are set, start Mutt. To switch from one account to another, just change the folder ({{ic|c}} key). Alternatively you can use the [[#Mutt-Sidebar|sidebar]].<br />
<br />
To change folder for different mailboxes you have to type the complete address -- for IMAP/POP3 folders, this may be quite inconvenient -- let us bind some key to it.<br />
<br />
{{bc|<br />
## Shortcuts<br />
macro index,pager <f2> '<sync-mailbox><enter-command>source ~/.mutt/personal<enter><change-folder>!<enter>'<br />
macro index,pager <f3> '<sync-mailbox><enter-command>source ~/.mutt/work<enter><change-folder>!<enter>'<br />
}}<br />
<br />
With the above shortcuts (or with the sidebar) you will find that changing folders (with {{ic|c}} by default) is not contextual, ''i.e.'' it will not list the folders of the current mailbox, but of the one used the last time you changed folders. To make the behaviour more contextual, the trick is to press ''='' or ''+'' for current mailbox. You can automate this with the following macro:<br />
macro index 'c' '<change-folder>?<change-dir><home>^K=<enter>'<br />
<br />
===Passwords management===<br />
Keep in mind that writing your password in {{ic|.muttrc}} is a security risk, and it might be of your concern.<br />
The trivial way to keep your passwords safe is not writing them in the config file. Mutt will then prompt for it when needed.<br />
However, this is quite cumbersome in the long run, especiallly if you have several accounts.<br />
<br />
Here follows a smart and convenient solution: all your passwords are encrypted into one file and Mutt will prompt for a passphrase on startup only. You can opt for a keyring tool (e.g. GPG, {{pkg|pwsafe}}) or an encryption tool like {{pkg|ccrypt}}, which may be more simple and straightforward to use.<br />
Since GPG is a Mutt dependency, we will use it here.<br />
<br />
First create a pair of public/private keys:<br />
gpg --gen-key<br />
If you do not understand this process have a look at [[Wikipedia:Asymmetric cryptography]].<br />
<br />
{{Expansion|What does "secure environment" mean?}}<br />
<br />
Create a file '''in a secure environment''' since it will contain your passwords for a couple of seconds:<br />
{{hc|~/.my-pwds|<nowiki><br />
set my_pw_personal = ****<br />
set my_pw_work = ****</nowiki><br />
}}<br />
<br />
{{Note|Remember that user defined variables '''must''' start with {{ic|my_}}.}}<br />
<br />
Now encrypt the file:<br />
gpg -e -r 'your-name' ~/.my-pwds<br />
Note that 'your-name' must match the one you provided at the {{ic|gpg --gen-key}} step.<br />
Now you can wipe your file containing your passwords in clear:<br />
shred -xu ~/.my-pwds<br />
Back to your account dedicated files, e.g. {{ic|.mutt/muttrc}}:<br />
{{bc|1=<br />
set imap_pass=$my_pw_personal<br />
# Every time the password is needed, use $my_pw_personal variable.<br />
}}<br />
<br />
And in your {{ic|.muttrc}}, '''before''' you source any account dedicated file:<br />
<br />
source "gpg2 -dq $HOME/.my-pwds.gpg |"<br />
<br />
{{Note|At the end of the line above, there is no space between the pipe and the double quote.}}<br />
* The {{ic|-q}} parameter makes gpg2 quiet which prevents gpg2 output messing with Mutt interface.<br />
* The pipe {{ic|<nowiki>|</nowiki>}} at the end of a string is the Mutt syntax to tell that you want the result of what is preceeding.<br />
<br />
Explanation: when Mutt starts, it will first source the result of the password decryption, that's why it will prompt for a passphrase. Then all passwords will be stored in memory in specific variables for the time Mutt runs. Then, when a folder-hook is called, it sets the imap_pass variable to the variable holding the appropriate password. When switching accounts, the imap_pass variable will be set to another variable holding another password, etc.<br />
<br />
If you use external tools like OfflineIMAP and msmtp, you need to set up an agent (e.g. gpg-agent, see [[GnuPG#gpg-agent]]) to keep the passphrase into cache and thus avoiding those tools always prompting for it.<br />
<br />
==== Security concern ====<br />
<br />
If {{ic|enter-command}} is available from the UI, it is possible to see the password unencrypted, which my be undesired if anybody else than you has access to your session while Mutt is running. You may want to disable it for this reason. As a consequence, every command that the user intends to use must be bound to a key in advance, otherwise it will never be accessible.<br />
{{hc|.muttrc|<br />
bind generic,alias,attach,browser,editor,index,compose,pager,pgp,postpone ':' noop<br />
}}<br />
<br />
==Advanced features==<br />
Guides to get you started with using & customizing Mutt : <br />
* [http://mutt.blackfish.org.uk/ My first Mutt] (maintained by Bruno Postle)<br />
* [http://www.therandymon.com/woodnotes/mutt/using-mutt.html The Woodnotes Guide to the Mutt Email Client] (maintained by Randall Wood)<br />
* [http://stevelosh.com/blog/2012/10/the-homely-mutt The Homely Mutt] (by Steve Losh)<br />
* [http://codesorcery.net/old/mutt/mutt-gnupg-howto Everything You Need To Know To Start Using GnuPG with Mutt] (by Justin R. Miller)<br />
<br />
If you have any Mutt specific questions, feel free to ask in [[ArchChannel|the irc channel]].<br />
<br />
===E-mail character encoding===<br />
You may be concerned with sending e-mail in a decent character set (charset for short) like UTF-8. Nowadays UTF-8 is highly recommended to almost everyone.<br />
<br />
When using Mutt there are two levels where the charset must be specified:<br />
* The text editor used to write the e-mail must save it in the desired encoding.<br />
* Mutt will then check the e-mail and determine which encoding is the more apropriate according to the priority you specified in the {{ic|send_charset}} variable. Default: "us-ascii:iso-8859-1:utf-8".<br />
<br />
So if you write an e-mail with characters allowed in ISO-8859-1 (like 'résumé'), but without characters specific to Unicode, then Mutt will set the encoding to ISO-8859-1.<br />
<br />
To avoid this behaviour, set the variable in your {{ic|muttrc}}:<br />
set send_charset="us-ascii:utf-8"<br />
or even<br />
set send_charset="utf-8"<br />
<br />
The first compatible charset starting from the left will be used.<br />
Since UTF-8 is a superset of US-ASCII it does not harm to leave it in front of UTF-8, it may ensure old MUA will not get confused when seeing the charset in the e-mail header.<br />
<br />
===Printing===<br />
You can install {{AUR|muttprint}} from the [[AUR]] for a fancier printing quality.<br />
In your muttrc file, insert:<br />
set print_command="/usr/bin/muttprint %s -p {PrinterName}"<br />
<br />
===Custom mail headers===<br />
One of the greatest thing in Mutt is that you can have full control over your mail header.<br />
<br />
First, make your headers editable when you write e-mails:<br />
set edit_headers=yes<br />
<br />
Mutt also features a special function {{ic|my_hdr}} for customizing your header. Yes, it is named just like a variable, but in fact it is a function.<br />
<br />
You can clear it completely, which you ''should'' do when switching accounts with different headers, otherwise they will overlap:<br />
unmy_hdr *<br />
<br />
Other variables have also an impact on the headers, so it is wise to clear them before using {{ic|my_hdr}}:<br />
unset use_from<br />
unset use_domain<br />
unset user_agent<br />
<br />
Now, you can add any field you want -- even non-standard one -- to your header using the following syntax:<br />
my_hdr <FIELD>: <VALUE><br />
Note that <VALUE> can be the result of a command.<br />
<br />
Example:<br />
{{bc|<br />
## Extra info.<br />
my_hdr X-Info: Keep It Simple, Stupid.<br />
<br />
## OS Info.<br />
my_hdr X-Operating-System: `uname -s`, kernel `uname -r`<br />
<br />
## This header only appears to MS Outlook users<br />
my_hdr X-Message-Flag: WARNING!! Outlook sucks<br />
<br />
## Custom Mail-User-Agent ID.<br />
my_hdr User-Agent: Every email client sucks, this one just sucks less.<br />
}}<br />
<br />
===Signature block===<br />
Create a .signature in your home directory. Your signature will be appended at the end of your email.<br />
Alternatively you can specify a file in your Mutt configuration:<br />
set signature="path/to/sig/file"<br />
====Random signature====<br />
You can use ''fortune'' (package {{Pkg|fortune-mod}}) to add a random signature to Mutt.<br />
<br />
Create a fortune file and then add the following line to your .muttrc:<br />
{{bc|1=set signature="fortune pathtofortunefile&#124;"}}<br />
Note the pipe at the end. It tells Mutt that the specified string is not a file, but a command.<br />
<br />
===Viewing URLs & opening your favorite web browser===<br />
Your should start by creating a .mutt directory in $HOME if not done yet. There, create a file named macros. Insert the following:<br />
macro pager \cb <pipe-entry>'urlview'<enter> 'Follow links with urlview'<br />
<br />
Then install {{AUR|urlview}} from the [[AUR]].<br />
<br />
Create a .urlview in $HOME and insert the following:<br />
REGEXP (((http|https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]<br />
COMMAND <your-browser> %s <br />
<br />
When you read an email on the pager, hitting ctrl+b will list all the urls from the email. Navigate up or down with arrow keys and hit enter on the desired url. Your browser will start and go to the selected site.<br />
<br />
Some browser will require additional arguments to work properly. For example, [[Luakit]] will close on Mutt exit. You need to fork it to background, using the {{ic|-n}} parameter:<br />
COMMAND luakit -n %s 2>/dev/null<br />
The {{ic|2>/dev/null}} is to make it quiet, i.e. to prevent useless message printing where you do not want them to.<br />
<br />
{{Note|urlview has a few deficiencies (e.g. the inability to handle certain email encodings) and is fairly feature-bare (e.g. it does not provide context for links it finds). There are a couple alternatives that do better. One, which can handle all email encodings and provides link context, is [http://www.memoryhole.net/~kyle/extract_url/ extract_url.pl]. Another, which can also provide link context but cannot handle all email encodings, is {{AUR|urlscan-git}}. Both are drop-in replacements for urlview, though extract_url has features which benefit from additional configuration changes.}}<br />
<br />
===Viewing HTML===<br />
It is possible to pass the html body to an external HTML program and then dump it, keeping email viewing uniform and unobtrusive. Three programs are described here: {{Pkg|lynx}}, {{Pkg|w3m}} and {{Pkg|elinks}} (make sure the selected package is [[pacman|installed]]).<br />
<br />
If {{ic|~/.mutt/mailcap}} does not exist you will need to create it and save the following to it.<br />
text/html; lynx -assume_charset=%{charset} -display_charset=utf-8 -dump %s; nametemplate=%s.html; copiousoutput<br />
or, in case of w3m,<br />
text/html; w3m -I %{charset} -T text/html; copiousoutput;<br />
or, in case of elinks,<br />
text/html; elinks -dump ; copiousoutput;<br />
<br />
Edit muttrc and add the following,<br />
set mailcap_path = ~/.mutt/mailcap<br />
<br />
To automatically open HTML messages in lynx, add this additional line to the muttrc:<br />
auto_view text/html<br />
<br />
The beauty of this is, instead of seeing an html body as source or being opened<br />
by a separate program, in this case lynx, you see the formatted content directly,<br />
and any url links within the email can be displayed with {{ic|Ctrl+b}}.<br />
<br />
If you receive many emails with multiple or alternate encodings Mutt may default to treating every email as html. To avoid this, add the following variable to your ~/.muttrc to have Mutt default to text when available and use w3m/lynx only when no text version is availble in the email:<br />
alternative_order text/plain text/html<br />
<br />
Some HTML mails may not display correctly in a text-based web browser. As a fallback solution, you can bind a key to open a graphical browser in such cases.<br />
The following macro will open the HTML mail selected from the attachment view in the web browser defined in the environment. (Feel free to adapt the {{ic|~/.cache/mutt/}} folder).<br />
macro attach 'V' "<pipe-entry>cat >~/.cache/mutt/mail.html && $BROWSER ~/.cache/mutt/mail.html && rm ~/.cache/mutt/mail.html<enter>"<br />
<br />
===Mutt and Vim===<br />
*To limit the width of text to 72 characters, edit your .[[vim]]rc file and add:<br />
au BufRead /tmp/mutt-* set tw=72<br />
<br />
*Another choice is to use Vim's mail filetype plugin to enable other mail-centric options besides 72 character width. Edit {{ic|~/.vim/filetype.vim}}, creating it if unpresent, and add:<br />
{{bc| <br />
augroup filetypedetect<br />
" Mail<br />
autocmd BufRead,BufNewFile *mutt-* setfiletype mail<br />
augroup END<br />
}}<br />
<br />
*To set a different tmp directory, e.g. ~/.tmp, add a line to your muttrc as follows:<br />
set tmpdir="~/.tmp"<br />
<br />
*To reformat a modified text see the Vim context help<br />
:h 10.7<br />
<br />
===Mutt and GNU nano===<br />
[[nano]] is another nice console editor to use with Mutt. <br />
<br />
To limit the width of text to 72 characters, edit your .nanorc file and add:<br />
set fill 72<br />
<br />
Also, in muttrc file, you can specify the line to start editing so that you will skip the mail header:<br />
set editor="nano +7"<br />
<br />
===Mutt and Emacs===<br />
Emacs has a ''mail'' and a ''message'' major mode.<br />
To switch to mail-mode automatically when Emacs is called from Mutt, you can add the following to your {{ic|.emacs}}:<br />
{{hc|.emacs|<nowiki><br />
;; Mutt support.<br />
(setq auto-mode-alist (append '(("/tmp/mutt.*" . mail-mode)) auto-mode-alist))<br />
</nowiki>}}<br />
<br />
If you usually run Emacs daemon, you may want Mutt to connect to it. Add this to your {{ic|.muttrc}}:<br />
{{hc|.muttrc|<nowiki><br />
set editor="emacsclient -a \"\" -t"</nowiki><br />
}}<br />
<br />
===Colors===<br />
Append sample color definitions to your .muttrc file:<br />
$ cat /usr/share/doc/mutt/samples/colors.linux >> ~/.muttrc<br />
Then adjust to your liking.<br />
The actual color each of these settings will produce depends on the colors set in your [[Xresources|~/.Xresources]] file.<br />
<br />
Alternatively, you can source any file you want containing colors (and thus act as a theme file):<br />
{{bc|<br />
source ~/.mutt/colors.zenburn<br />
}}<br />
<br />
A nice theme example:<br />
{{bc|<nowiki><br />
## Theme kindly inspired from <br />
## http://nongeekshandbook.blogspot.ie/2009/03/mutt-color-configuration.html <br />
<br />
## Colours for items in the index <br />
color index brightcyan black ~N<br />
color index brightred black ~O<br />
color index brightyellow black ~F<br />
color index black green ~T<br />
color index brightred black ~D<br />
mono index bold ~N<br />
mono index bold ~F<br />
mono index bold ~T<br />
mono index bold ~D<br />
<br />
## Highlights inside the body of a message. <br />
<br />
## URLs <br />
color body brightgreen black "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"<br />
color body brightgreen black "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"<br />
mono body bold "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"<br />
mono body bold "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"<br />
<br />
## Email addresses. <br />
color body brightgreen black "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"<br />
<br />
## Header <br />
color header green black "^from:"<br />
color header green black "^to:"<br />
color header green black "^cc:"<br />
color header green black "^date:"<br />
color header yellow black "^newsgroups:"<br />
color header yellow black "^reply-to:"<br />
color header brightcyan black "^subject:"<br />
color header red black "^x-spam-rule:"<br />
color header green black "^x-mailer:"<br />
color header yellow black "^message-id:"<br />
color header yellow black "^Organization:"<br />
color header yellow black "^Organisation:"<br />
color header yellow black "^User-Agent:"<br />
color header yellow black "^message-id: .*pine"<br />
color header yellow black "^X-Fnord:"<br />
color header yellow black "^X-WebTV-Stationery:"<br />
<br />
color header red black "^x-spam-rule:"<br />
color header green black "^x-mailer:"<br />
color header yellow black "^message-id:"<br />
color header yellow black "^Organization:"<br />
color header yellow black "^Organisation:"<br />
color header yellow black "^User-Agent:"<br />
color header yellow black "^message-id: .*pine"<br />
color header yellow black "^X-Fnord:"<br />
color header yellow black "^X-WebTV-Stationery:"<br />
color header yellow black "^X-Message-Flag:"<br />
color header yellow black "^X-Spam-Status:"<br />
color header yellow black "^X-SpamProbe:"<br />
color header red black "^X-SpamProbe: SPAM"<br />
<br />
## Coloring quoted text - coloring the first 7 levels: <br />
color quoted cyan black<br />
color quoted1 yellow black<br />
color quoted2 red black<br />
color quoted3 green black<br />
color quoted4 cyan black<br />
color quoted5 yellow black<br />
color quoted6 red black<br />
color quoted7 green black<br />
<br />
## Default color definitions <br />
#color hdrdefault white green <br />
color signature brightmagenta black<br />
color indicator black cyan<br />
color attachment black green<br />
color error red black<br />
color message white black<br />
color search brightwhite magenta<br />
color status brightyellow blue<br />
color tree brightblue black<br />
color normal white black<br />
color tilde green black<br />
color bold brightyellow black<br />
#color underline magenta black <br />
color markers brightcyan black<br />
<br />
## Colour definitions when on a mono screen <br />
mono bold bold<br />
mono underline underline<br />
mono indicator reverse</nowiki><br />
}}<br />
<br />
===Index Format===<br />
<br />
Here follows a quick example to put in your {{ic|.muttrc}} to customize the Index Format, i.e. the columns displayed in the folder view.<br />
{{bc|<nowiki><br />
set date_format="%y-%m-%d %T"<br />
set index_format="%2C | %Z [%d] %-30.30F (%-4.4c) %s"</nowiki><br />
}}<br />
See the [http://www.mutt.org/doc/manual/manual-6.html Mutt Reference], {{ic|man 3 strftime}} and {{ic|man 3 printf}} for more details.<br />
<br />
====Display recipient instead of sender in "Sent" folder view====<br />
<br />
By default Mutt will display the sender in the index view. It is fine for most folders, but rather useless for the one were you store a copy of your sent e-mails since it will always display your name.<br />
<br />
The "columns" of the index can be configured through the {{ic|index_format}} variable. Its syntax is documented in the {{ic|muttrc}} man page. The values of our concern are {{ic|%t}} (recipient) and {{ic|%F}} (sender).<br />
<br />
To change the columns according to the current folder, we need to use a hook:<br />
{{hc|muttrc|<nowiki><br />
folder-hook *[sS]ent* 'set index_format="%2C | %Z [%d] %-30.30t (%-4.4c) %s"'<br />
folder-hook ! *[sS]ent* 'set index_format="%2C | %Z [%d] %-30.30F (%-4.4c) %s"'<br />
</nowiki>}}<br />
<br />
The exclamation mark means ''everything that does not match the following regex''. Of course you can change the index_format following you taste, and the regular expression if the folder does not have ''Sent'' not ''sent'' in its name.<br />
<br />
====Variable column width====<br />
<br />
If you resize the window, the subject might get truncated while there is still unused space left for some fields, like for the sender.<br />
You can get the maximum number of columns supported by your terminal (i.e. the width) using a shell call to {{ic|tput cols}}. With this value, you can set a percentage of the width to fields like Sender and Subject.<br />
<br />
Example using the above folder-hook and a sidebar width of 24:<br />
{{hc|muttrc|<nowiki><br />
## From field gets 30% of remaining space, Subject gets 70%.<br />
## Remaining space is the total width minus the other fields (35), minus the sidebar (24)<br />
set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`<br />
set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`<br />
<br />
folder-hook .*[sS]ent.* 'set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}t (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
folder-hook ! .*[sS]ent.* 'set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}F (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
</nowiki><br />
}}<br />
<br />
Unfortunately, the above example suffers from one caveat: the {{ic|my_col_*}} variables get computed one time only, on first start. So if you want it to refresh automatically, we need to set the variable in a hook. Sadly there is no hook for window resizing, but you can still use the {{ic|folder-hook}} so that a simple folder switch suffices to recompute the view.<br />
{{hc|muttrc|<nowiki><br />
folder-hook .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`; set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}t (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
folder-hook ! .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`; set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}F (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
</nowiki><br />
}}<br />
<br />
===Contact management===<br />
<br />
====Address aliases====<br />
''Aliases'' is the way Mutt manages contacts.<br />
An alias is '''nickname [longname] <address>'''.<br />
* The '''nickname''' is what you will type in Mutt to get your contact address. One word only, and should be easy to remember.<br />
* The '''longname''' is optional. It may be several words.<br />
* An '''<address>''' must be in a valid form (i.e. with an {{ic|@}}).<br />
<br />
It is quite simple indeed. Add this to {{ic|.muttrc}}:<br />
{{bc|1=<br />
set alias_file = "~/.mutt/aliases"<br />
set sort_alias = alias<br />
set reverse_alias = yes<br />
source $alias_file<br />
}}<br />
<br />
Explanation:<br />
* {{ic|alias_file}} is the file where the information is getting stored when you add an alias from within Mutt.<br />
* {{ic|sort_alias}} specifies which field to use to sort the alias list when displayed in Mutt. Possible values: alias, address.<br />
* {{ic|reverse_alias}} sorts in reverse order if set to yes.<br />
* {{ic|source $alias_file}} tells Mutt to read aliases on startup. Needed for auto-completion.<br />
<br />
Now all you have to do when prompted {{ic|To:}} is writing the alias instead of the full address. The beauty of it is that you can auto-complete the alias using {{ic|Tab}}.<br />
Autocompleting a wrong or an empty string will display the full list. You can select the alias as usual, or by typing its index number.<br />
<br />
There are two ways to create aliases:<br />
* From Mutt, press {{ic|a}} when an e-mail of the targetted person if selected.<br />
* Edit the alias_file manually. The syntax is really simple:<br />
{{bc|<br />
alias nickname Long Name <my-friend@domain.tld><br />
}}<br />
<br />
====Abook====<br />
<br />
{{pkg|abook}} is a stand-alone program dedicated to contact management. It uses a very simple text-based interface and contacts are stored in a plain text, human-readable database. Besides the desired contact properties are extensible (birthday, address, fax, and so on).<br />
<br />
Abook is specifically designed to be interfaced with Mutt, so that it can serve as a full, more featured replacement of Mutt internal aliases. If you want to use Abook instead of aliases, remove the aliases configuration in {{ic|.muttrc}} and add this:<br />
<br />
{{hc|muttrc|<nowiki><br />
## Abook<br />
set query_command= "abook --mutt-query '%s'"<br />
macro index,pager a "<pipe-message>abook --add-email-quiet<return>" "Add this sender to Abook"<br />
bind editor <Tab> complete-query<br />
</nowiki><br />
}}<br />
<br />
See the man pages {{ic|abook}} and {{ic|abookrc}} for more details and a full configuration sample.<br />
<br />
====Goobook====<br />
<br />
Goobook allows you to search your Google contacts from the command line or from within Mutt. {{AUR|goobook-git}} can be installed from AUR. <br />
<br />
Before using goobook you must configure {{ic|~/.goobookrc}}. To generate the default template: <br />
$ goobook config-template > ~/.goobookrc<br />
<br />
See {{ic|~/.goobookrc}} for configuration options. At a minimum, you will need to enter your '''email''' and '''password'''.<br />
<br />
{{Note|If you have two-step verification enabled with the Google account, you may need to generate an application password. <br />
}}<br />
<br />
If you want to use Goobook instead of aliases, remove any alias configuration in {{ic|.muttrc}} and add:<br />
{{hc|muttrc|<nowiki><br />
## GooBook<br />
set query_command="goobook query '%s'"<br />
macro index,pager a "<pipe-message>goobook add<return>" "add sender to google contacts"<br />
bind editor <Tab> complete-query<br />
</nowiki><br />
}}<br />
<br />
When composing an email message within mutt, {{ic|Tab}} will now search your Google contacts. While viewing messages {{ic|a}} will add the sender to Google contacts.<br />
<br />
===Request IMAP mail retrieval manually===<br />
If you do not want to wait for the next automatic IMAP fetching (or if you did not enable it), you might want to fetch mails manually.<br />
There is a mutt command {{ic|imap-fetch-mail}} for that.<br />
Alternatively, you could bind it to a key:<br />
bind index "^" imap-fetch-mail<br />
<br />
===Avoiding slow index on large (IMAP) folders due to coloring===<br />
<br />
Index highlighting by regex is nice, but can lead to slow folder viewing if your regex checks the body of the message.<br />
<br />
Use folder-hook for only highlighting in for example the inbox (if you manage to empty your mailbox effiently):<br />
<br />
folder-hook . 'uncolor index "~b \"Hi Joe\" ~R !~T !~F !~p !~P"'<br />
folder-hook ""!"" 'color index brightyellow black "~b \"Hi Joe\" ~N !~T !~F !~p !~P"'<br />
<br />
===Speed up folders switch===<br />
Add this to your {{ic|.muttrc}}:<br />
{{bc|1=<br />
set sleep_time = 0<br />
}}<br />
<br />
===Use Mutt to send mail from command line===<br />
Man pages will show all available commands and how to use them, but here are a couple of examples. You could use Mutt to send alerts, logs or some other system information, triggered by login through .bash_profile, or as a regular cron job.<br />
<br />
Send a message:<br />
mutt -s "Subject" somejoeorjane@someserver.com < /var/log/somelog<br />
<br />
Send a message with attachment:<br />
mutt -s "Subject" somejoeorjane@someserver.com -a somefile < /tmp/sometext.txt<br />
<br />
===Composing HTML e-mails===<br />
<br />
Since Mutt has nothing of a WYSIWIG client, HTML is quite straightforward, and you can do much more than with all WYSIWIG mail clients around since you edit the source code directly.<br />
Simply write your mail using HTML syntax. For example:<br />
{{bc|<nowiki><br />
This is normal text<br><br />
<b>This is bold text</b></nowiki><br />
}}<br />
Now before sending the mail, use the {{ic|edit-type}} command (default shortcut {{ic|Ctrl+t}}), and replace {{ic|text/plain}} by {{ic|text/html}}.<br />
<br />
{{Note|HTML e-mails are regarded by many people as useless, cumbersome, and subject to reading issues. Mutt can read HTML mails with a text browser like w3m or lynx, but it has clearly no advantage over a plain-text e-mail. You should avoid writing HTML e-mails when possible.}}<br />
<br />
===How to display another email while composing===<br />
A common complaint with Mutt is that when composing a new mail (or reply), you cannot open another mail (i.e. for checking with another correspondent) without closing the current mail (postponing). The following describes a solution:<br />
<br />
First, fire up Mutt as usual. Then, launch another terminal window. Now start a new Mutt with <br />
mutt -R<br />
This starts Mutt in read-only mode, and you can browse other emails at your convenience. It is strongly recommended to always launch a second Mutt in read-only mode, as conflicts will easily arise otherwise.<br />
<br />
{{Note|When changing folders (with {{ic|c}} or {{ic|y}}) the read-only mode is not preserved. Instead {{ic|Esc c}} has to be used.}}<br />
<br />
{{Tip|This solution calls for a bit of typing, so it is suitable to bind the following command to a keyboard shortcut (see [[Extra Keyboard Keys]] for details):<br />
$TERMINAL -e mutt -R <br />
where {{ic|$TERMINAL}} is your terminal.}}<br />
<br />
===Archive treated e-mails===<br />
When you read an e-mail, you have four choices: Answer it, Flag it, Archive it or Delete it. If you have this in mind, you can keep your inbox slim and fit with this macro (set up for Gmail):<br />
<br />
macro index \' "<tag-pattern>~R !~D !~F<enter>\<br />
<tag-prefix><save-message>+[Gmail]/All <enter>" \<br />
"Archive"<br />
<br />
===Mutt-Sidebar===<br />
<br />
The vanilla Mutt does not feature a sidebar unlike most MUAs. If you miss it, you can install {{AUR|mutt-sidebar}} from the AUR which features a patch for a list of folders on the left side of the Mutt window.<br />
<br />
For a while there has been several different patches for the sidebar. Since the late 2000's, it seems like the main patch is maintained at [http://www.lunar-linux.org/mutt-sidebar/ Lunar Linux]. See the documentation there. Note that the patch also updates the {{ic|muttrc}} man page, so have a look at the {{ic|sidebar_*}} sections.<br />
<br />
You can choose to display the sidebar on startup, or to prompt it manually with a key:<br />
{{bc|<nowiki><br />
set sidebar_visible = yes<br />
macro index b '<enter-command>toggle sidebar_visible<enter><refresh>'<br />
macro pager b '<enter-command>toggle sidebar_visible<enter><redraw-screen>'<br />
</nowiki>}}<br />
<br />
You also probabaly need some shortcuts to navigate in the bar:<br />
{{bc|<nowiki><br />
# Ctrl-n, Ctrl-p to select next, previous folder.<br />
# Ctrl-o to open selected folder.<br />
bind index,pager \CP sidebar-prev<br />
bind index,pager \CN sidebar-next<br />
bind index,pager \CO sidebar-open<br />
</nowiki>}}<br />
<br />
{{Note|You ''must'' set the {{ic|mailboxes}} variables or the {{ic|imap_check_subscribed}} to tell the sidebar which folder should be displayed. See the [[#mailboxes|mailboxes]] section.}}<br />
<br />
If you use the {{ic|imap_check_subscribed}} option to list all your folders, they will appear in an uncontrollable order in the sidebar. Fix it with<br />
set sidebar_sort = yes<br />
Note that with the {{ic|mailboxes}} option, folders appear in the order they were set to {{ic|mailboxes}} if you do not use the {{ic|sidebar_sort}} option.<br />
<br />
If you have trouble with truncated names, set the option<br />
set sidebar_shortpath = yes<br />
<br />
Finally, you may want to add a separator between different mailboxes. The sidebar patch does not currently provide any kind of separator option. A simple (and dirty) workaround is to add a fake folder to the list of folders:<br />
mailboxes "+-- My mailbox -----------"<br />
The dashes are not required, they are here just for fancy output.<br />
It will also work if you used the {{ic|imap_check_subscribed}} option.<br />
If you chose to sort the folders, the separator will not appear in the correct place, so an even more dirty workaround is to add an 'A' in front of the name. Note that punctuation is ignored during sorting.<br />
mailboxes "+A-- My mailbox -----------"<br />
<br />
===Migrating mails from one computer to another===<br />
In case you are transfering your mails to a new machine (copy&paste), you probably need to delete the header cache (a file or folder like {{ic|~/.cache/mutt}} if you followed the above configuration) to make Mutt able to read your migrated E-Mails. Otherwise Mutt may freeze.<br />
<br />
Note that if you had a folder created for you header cache, all mailboxes will have their own cache file, so you can delete caches individually without having to remove everything.<br />
<br />
=== Filtering the message view ===<br />
<br />
You can restrict the view to e-mails matching a pattern and specific properties with the {{ic|limit}} command (default shortcut: {{ic|l}}).<br />
<br />
To view all e-mails containing "foo" in the header, simply write "foo" and you are done. To remove the filter, use the "all" keyword.<br />
<br />
To view all flagged messages, use<br />
~F<br />
To view all unread messages, use<br />
~U<br />
<br />
All possible patterns are listed in the [http://www.mutt.org/doc/manual/manual-4.html#ss4.2 official manual].<br />
<br />
=== Display the index above the pager view ===<br />
<br />
Set the following variable in your {{ic|muttrc}}:<br />
set pager_index_lines=10<br />
<br />
==Troubleshooting==<br />
<br />
===Backspace does not work in Mutt===<br />
This is a common problem with some xterm-like terminals.<br />
Two solutions:<br />
* Either rebind the key in {{ic|.muttrc}}<br />
bind index,pager ^? previous-line<br />
Note that {{ic|^?}} is one single character representing backspace in [[wikipedia:Caret_notation|caret notation]]. To type in Emacs, use {{ic|Ctrl+q Backspace}}, in Vim {{ic|Ctrl+v Backspace}}.<br />
<br />
* Or fix your terminal:<br />
$ infocmp > termbs.src<br />
Edit {{ic|termbs.src}} and change {{ic|1= kbs=^H}} to {{ic|1= kbs=\177}}, then:<br />
$ tic -x termbs.src<br />
<br />
===Android's default MUA receives empty e-mail with attachment "Unknown.txt"===<br />
<br />
This is because Mutt adds 'Content-Disposition' line to every e-mail header. This line is actually correct, the issue comes from Android 2 MUA misinterpreting it. This bug seems to be fixed in the Android 4 MUA.<br />
There is a patched version for Android available in the AUR. Installing {{AUR|mutt-android-patch}} will fix the issue.<br />
<br />
===The ''change-folder'' function always prompt for the same mailbox ===<br />
<br />
This is not a bug, this is actually an intended behaviour. See the [[#Multiple accounts|multiple accounts section]] for a workaround.<br />
<br />
===I cannot change folder when using Mutt read-only (Mutt -R)===<br />
<br />
This is certainly because you are using macros like this one:<br />
macro index,pager <f2> '<sync-mailbox><enter-command>source ~/.mutt/personal<enter><change-folder>!<enter>'<br />
This macro tells Mutt to sync (which is a write operation) before switching.<br />
Either use the [[#Mutt-Sidebar|sidebar]] or set another macro:<br />
macro index,pager <f3> '<enter-command>source ~/.mutt/personal<enter><change-folder>!<enter>'<br />
<br />
===Error sending message, child exited 127 (Exec error.).===<br />
This is an SMTP error. It means that mutt does not know how to send the message.<br />
You can either try installing sendmail and see if that solves your issue, or you can set the smtp_url variable. If you use gmail, you can add the following to your muttrc to tell mutt to use gmails smtp server.<br />
<br />
set smtp_url=smtps://$imap_user:$imap_pass@smtp.gmail.com<br />
<br />
Take note of the smtps protocol, it is important.<br />
This should solve the problem.<br />
<br />
== Documentation ==<br />
<br />
Newcomers may find it quite hard to find help for Mutt. Actually most of the topics are covered in the official documentation. We urge you to read it.<br />
<br />
* [http://www.mutt.org/doc/manual/ The official manual]. The stock {{pkg|mutt}} package for Arch Linux also installs the HTML and plain text manual at {{ic|/usr/share/doc/mutt/}}.<br />
* The {{ic|mutt}} and {{ic|muttrc}} man pages.<br />
<br />
== See also ==<br />
* [http://www.mutt.org/ The official Mutt website]<br />
* [http://wiki.mutt.org/ The Mutt wiki]<br />
* [http://pbrisbin.com/posts/two_accounts_in_mutt/ Brisbin's great guide on how to setup different IMAP accounts with Mutt, offlineimap, msmtp]<br />
* [http://srobb.net/mutt.html A Quick Guide to Mutt]<br />
* [http://stevelosh.com/blog/2012/10/the-homely-mutt/ Steve Losh on Mutt, offlineimap, msmtp, notmuch (focused on Gmail)]<br />
* [http://www.muttrcbuilder.org/ muttrc builder]</div>Paris3200https://wiki.archlinux.org/index.php?title=Mutt&diff=367404Mutt2015-03-27T16:12:46Z<p>Paris3200: /* Contact management */</p>
<hr />
<div>[[Category:Email clients]]<br />
[[es:Mutt]]<br />
[[it:Mutt]]<br />
[[zh-CN:Mutt]]<br />
[[zh-TW:Mutt]]<br />
{{Related articles start}}<br />
{{Related|fdm}}<br />
{{Related|msmtp}}<br />
{{Related|offlineimap}}<br />
{{Related|isync}}<br />
{{Related articles end}}<br />
'''Mutt''' is a text-based mail client renowned for its powerful features. Though over a decade old, Mutt remains the mail client of choice for a great number of power-users. Unfortunately, a default Mutt install is plagued by complex keybindings along with a daunting amount of documentation. This guide will help the average user get Mutt up and running, and begin customizing it to their particular needs.<br />
<br />
==Overview==<br />
Mutt focuses primarily on being a Mail User Agent (MUA), and was originally written to view mail. Later implementations (added for retrieval, sending, and filtering mail) are simplistic compared to other mail applications and, as such, users may wish to use external applications to extend Mutt's capabilities. <br />
<br />
Nevertheless, the Arch Linux {{Pkg|mutt}} package is compiled with IMAP, POP3 and SMTP support, removing the necessity for external applications.<br />
<br />
This article covers using both native IMAP sending and retrieval, and a setup depending on [[OfflineIMAP]] or [[getmail]] (POP3) to retrieve mail, [[procmail]] to filter it in the case of POP3, and [[msmtp]] to send it.<br />
<br />
==Installing==<br />
[[pacman|Install]] {{Pkg|mutt}}, available in the [[official repositories]]. <br />
<br />
Optionally install external helper applications for an IMAP setup, such as [[isync]], [[OfflineIMAP]], or [[msmtp]].<br />
<br />
Or (if using POP3) {{Pkg|getmail}}, {{Pkg|fetchmail}} or {{Pkg|fdm}} and {{Pkg|procmail}}.<br />
<br />
{{Note|<br />
*If you just need the authentication methods LOGIN and PLAIN, these are satisfied with the dependency {{Pkg|libsasl}}<br />
*If you want to (or have to) use CRAM-MD5, GSSAPI or DIGEST-MD5, install the package {{Pkg|cyrus-sasl-gssapi}}<br />
*If you are using Gmail as your SMTP server, you may need to install the package {{Pkg|cyrus-sasl}}<br />
}}<br />
<br />
==Configuring==<br />
This section covers [[#IMAP]], [[#POP3]], [[#Maildir]] and [[#SMTP]] configuration.<br />
<br />
Note that Mutt will recognize by default two locations for its configuration file; {{ic|~/.muttrc}} and {{ic|~/.mutt/muttrc}}. Either location will work. In case you decide to put the initialization file somewhere else, use {{ic|$ mutt -F /path/to/.muttrc}}.<br />
You should also know some prerequisite for Mutt configuration. Its syntax is very close to the Bourne Shell. For example, you can get the content of another config file:<br />
source /path/to/other/config/file<br />
You can use variables and assign the result of shell commands to them.<br />
set editor=`echo \$EDITOR`<br />
Here the {{ic|$}} gets escaped so that it does not get substituted by Mutt before being passed to the shell.<br />
Also note the use of the backquotes, as bash syntax {{ic|$(...)}} does not work.<br />
Mutt has a lot of predefined variables, but you can also set your own. User variable '''must begin with "my"!'''<br />
set my_name = "John Doe"<br />
<br />
===IMAP===<br />
<br />
====Native IMAP support====<br />
The pacman version of Mutt is compiled with IMAP support. At the very least you need to have 4 lines in your muttrc file to be able to access your mail.<br />
<br />
=====imap_user=====<br />
set imap_user=USERNAME<br />
<br />
{{Tip|Continuing with the previous example, remember that Gmail requires your full email address (this is not standard): {{bc|1=set imap_user=your.username@gmail.com}}}}<br />
<br />
=====imap_pass=====<br />
If unset, the password will be prompted for.<br />
set imap_pass=SECRET<br />
<br />
{{Tip|If you have enabled two-factor authentication in Gmail and you have added an application specific password for Mutt, you will want to use that password here rather than your regular Gmail password.}}<br />
<br />
=====folder=====<br />
Instead of a local directory which contains all your mail (and directories), use your server (and the highest folder in the hierarchy, if needed).<br />
set folder=imap[s]://imap.server.domain[:port]/[folder/]<br />
<br />
You do not have to use a folder, but it might be convenient if you have all your other folders inside your INBOX, for example. Whatever you set here as your folder can be accessed later in Mutt with just an equal sign (=) or a plus sign (+). Example:<br />
set folder=imaps://imap.gmail.com/<br />
<br />
It should be noted that for several accounts, it is best practice to use different folders -- e.g. for ''account-hook''. If you have several Gmail account, use<br />
set folder=imaps://username@imap.gmail.com/<br />
instead, where your account is ''username@gmail.com''. This way it will be possible to distinguish the different folders. Otherwise it would lead to authentication errors.<br />
<br />
=====spoolfile=====<br />
The spoolfile is the folder where your (unfiltered) e-mail arrives. Most e-mail services conventionally names it ''INBOX''. You can now use '=' or '+' as a substitution for the full {{ic|folder}} path that was configured above. For example:<br />
set spoolfile=+INBOX<br />
<br />
=====mailboxes=====<br />
Any imap folders that should be checked regularly for new mail should be listed here:<br />
mailboxes =INBOX =family<br />
mailboxes imaps://imap.gmail.com/INBOX imaps://imap.gmail.com/family<br />
<br />
Alternatively, check for all subscribed IMAP folders (as if all were added with a {{Ic|mailboxes}} line):<br />
set imap_check_subscribed<br />
<br />
These two versions are equivalent if you want to subscribe to all folders. So the second method is much more convenient, but the first one gives you more flexibility. Also, newer Mutt versions are configured by default to include a macro bound to the 'y' key which will allow you to change to any of the folders listed under mailboxes.<br />
<br />
If you do not set this variable, the ''spoolfile'' will be used by default.<br />
This variable is also important for the [[#Mutt-Sidebar|sidebar]].<br />
<br />
=====Summary=====<br />
Using these options, you will be able to start Mutt, enter your IMAP password, and start reading your mail. Here is a muttrc snippet (for Gmail) with some other lines you might consider adding for better IMAP support.<br />
{{bc|1=<br />
set folder = imaps://imap.gmail.com/<br />
set imap_user = your.username@gmail.com<br />
set imap_pass = your-imap-password<br />
set spoolfile = +INBOX<br />
mailboxes = +INBOX<br />
<br />
# Store message headers locally to speed things up.<br />
# If hcache is a folder, Mutt will create sub cache folders for each account which may speeds things up even more.<br />
set header_cache = ~/.cache/mutt<br />
<br />
# Store messages locally to speed things up, like searching message bodies.<br />
# Can be the same folder as header_cache.<br />
# This will cost important disk usage according to your e-mail amount.<br />
set message_cachedir = "~/.cache/mutt"<br />
<br />
# Specify where to save and/or look for postponed messages.<br />
set postponed = +[Gmail]/Drafts<br />
<br />
# Allow Mutt to open new imap connection automatically.<br />
unset imap_passive<br />
<br />
# Keep IMAP connection alive by polling intermittently (time in seconds).<br />
set imap_keepalive = 300<br />
<br />
# How often to check for new mail (time in seconds).<br />
set mail_check = 120<br />
}}<br />
<br />
====External IMAP support====<br />
While IMAP support is built into Mutt, it does not download mail for offline use. It is possible to use an external application such as [[OfflineIMAP]] or [[isync]] to download your emails to a local folder which can then be processed by Mutt.<br />
<br />
Consider using applications such as {{pkg|spamassassin}} or {{AUR|imapfilter}} to sort mail.<br />
<br />
===POP3===<br />
One popular option is to use [[getmail]] for retrieving and [[procmail]] for filtering the mail.<br />
<br />
===Maildir===<br />
Maildir is a generic and standardized format. Almost every MUA is able to handle Maildirs and Mutt's support is excellent. There are just a few simple things that you need to do to get Mutt to use them. Open your muttrc and add the following lines:<br />
{{bc|1=<br />
set mbox_type=Maildir<br />
set folder=$HOME/mail<br />
set spoolfile=+/<br />
set header_cache=~/.cache/mutt<br />
}}<br />
<br />
This is a minimal Configuration that enables you to access your Maildir and checks for new local Mails in INBOX. This configuration also caches the headers of the eMails to speed up directory-listings. It might not be enabled in your build (but it sure is in the Arch-Package). Note that this does not affect OfflineIMAP in any way. It always syncs the all directories on a Server. {{ic|spoolfile}} tells Mutt which local directories to poll for new Mail. You might want to add more Spoolfiles (for example the Directories of Mailing-Lists) and maybe other things. But this is subject to the Mutt manual and beyond the scope of this document.<br />
<br />
===SMTP===<br />
Whether you use POP or IMAP to receive mail you will probably still send mail using SMTP.<br />
<br />
==== Folders ====<br />
<br />
There is basically only one important folder here: the one where all your sent e-mails will be saved.<br />
set record = +Sent<br />
<br />
Gmail saves automatically sent e-mail to {{ic|+[Gmail]/Sent}}, so we do not want<br />
duplicates.<br />
unset record<br />
<br />
====Native SMTP support====<br />
The official {{Pkg|mutt}} is also compiled with SMTP support.<br />
<br />
For example:<br />
{{bc|1=<br />
set my_pass='mysecretpass'<br />
set my_user=myname<br />
<br />
set realname = 'Your Real Name'<br />
set from = your-email-address<br />
set use_from = yes<br />
<br />
set smtp_url=smtps://$my_user:$my_pass@smtp.domain.tld<br />
set ssl_force_tls = yes<br />
}}<br />
<br />
Note that if your SMTP credentials are the same as your IMAP credentials, then you can use those variables:<br />
<br />
{{bc|1=<br />
set smtp_url=smtps://$imap_user:$imap_pass@smtp.domain.tld<br />
}}<br />
<br />
You may need to tweak the security parameters. If you get an error like<br />
{{ic|SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol}},<br />
then your server probably uses the SMTP instead of SMTPS.<br />
<br />
{{bc|1=<br />
set smtp_url=smtp://$imap_user:$imap_pass@smtp.domain.tld<br />
}}<br />
<br />
There are other variables that you may need to set. For example for use of STARTTLS:<br />
{{bc|1=<br />
set ssl_starttls = yes<br />
}}<br />
<br />
See {{ic|man 5 muttrc}} for more information.<br />
<br />
====External SMTP support====<br />
<br />
An external SMTP agent such as [[msmtp]], [[SSMTP]] or {{Pkg|opensmtpd}} can also be used.<br />
<br />
The {{ic|sendmail}} variable in your {{ic|muttrc}} determines the program and arguments used to deliver mail in mutt. Any additional arguments must be interpreted by the program as recipient addresses.<br />
<br />
For example, if using [[msmtp]]:<br />
<br />
{{hc|muttrc|2=<br />
set realname='Disgruntled Kangaroo'<br />
<br />
set sendmail="/usr/bin/msmtp"<br />
<br />
set edit_headers=yes<br />
set folder=~/mail<br />
set mbox=+mbox<br />
set spoolfile=+inbox<br />
set record=+sent<br />
set postponed=+drafts<br />
set mbox_type=Maildir<br />
<br />
mailboxes +inbox +lovey-dovey +happy-kangaroos<br />
}}<br />
<br />
====Sending mails from Mutt====<br />
Now, startup {{Ic|mutt}}:<br />
<br />
You should see all the mail in {{ic|~/mail/inbox}}. Press {{ic|m}} to compose mail; it will use the editor defined by your {{Ic|EDITOR}} environment variable. If this variable is not set, you can fix it before starting Mutt:<br />
$ export EDITOR=your-favorite-editor<br />
$ mutt<br />
<br />
You should store the EDITOR value into your shell resource configuration file (such as [[bashrc]]).<br />
You can also set the editor from Mutt's configuration file:<br />
{{hc|.muttrc|2=<br />
set editor=your-favorite-editor<br />
}}<br />
<br />
For testing purposes, address the letter to yourself. After you have written the letter, save and exit the editor. You will return to Mutt, which will now show information about your e-mail. Press {{ic|y}} to send it.<br />
<br />
===Multiple accounts===<br />
<br />
Now you should have a working configuration for one account at least. You might wonder how to use several accounts, since we put everything into a single file.<br />
<br />
Well all you need is to write account-specific parameters to their respective files and source them. All the IMAP/POP3/SMTP config for each account should go to its respective folder.<br />
{{Warning|When one account is setting a variable that is not specified for other accounts, you '''must unset''' it for them, otherwise configuration will overlap and you will most certainly experience unexpected behaviour.}}<br />
<br />
Mutt can handle this thanks to one of its most powerful features: hooks.<br />
Basically a hook is a command that gets executed before a specific action.<br />
There are several hooks available. For multiple accounts, you must use account-hooks ''and'' folder-hooks.<br />
* Folder-hooks will run a command before switching folders. This is mostly useful to set the appropriate SMTP parameters when you are in a specific folder. For instance when you are in your work mailbox and you send a e-mail, it will automatically use your work account as sender.<br />
* Account-hooks will run a command everytime Mutt calls a function related to an account, like IMAP syncing. It does not require you to switch to any folder.<br />
<br />
Hooks take two parameters:<br />
account-hook [!]regex command<br />
folder-hook [!]regex command<br />
The regex is the folder to be matched (or not if preceded by the !).<br />
The command tells what to do.<br />
<br />
Let us give a full example:<br />
<br />
{{hc|.muttrc|<nowiki><br />
## General options<br />
set header_cache = "~/.cache/mutt"<br />
set imap_check_subscribed<br />
set imap_keepalive = 300<br />
unset imap_passive<br />
set mail_check = 60<br />
set mbox_type=Maildir<br />
<br />
## ACCOUNT1<br />
source "~/.mutt/work"<br />
# Here we use the $folder variable that has just been set in the sourced file.<br />
# We must set it right now otherwise the 'folder' variable will change in the next sourced file.<br />
folder-hook $folder 'source ~/.mutt/work'<br />
<br />
## ACCOUNT2<br />
source "~/.mutt/personal"<br />
folder-hook *user@gmail.com/ 'source ~/.mutt/personal'<br />
folder-hook *user@gmail.com/Family 'set realname="Bob"'<br />
</nowiki>}}<br />
<br />
{{hc|.mutt/work|<nowiki><br />
## Receive options.<br />
set imap_user=user@gmail.com<br />
set imap_pass=****<br />
set folder = imaps://user@imap.gmail.com/<br />
set spoolfile = +INBOX<br />
set postponed = +Drafts<br />
set record = +Sent<br />
<br />
## Send options.<br />
set smtp_url=smtps://user:****@smtp.gmail.com<br />
set realname='User X'<br />
set from=user@gmail.com<br />
set hostname="gmail.com"<br />
set signature="John Doe"<br />
# Connection options<br />
set ssl_force_tls = yes<br />
unset ssl_starttls<br />
<br />
## Hook -- IMPORTANT!<br />
account-hook $folder "set imap_user=user@gmail.com imap_pass=****"<br />
</nowiki>}}<br />
<br />
Finally {{ic|.mutt/personal}} should be similar to {{ic|.mutt/work}}.<br />
<br />
Now all your accounts are set, start Mutt. To switch from one account to another, just change the folder ({{ic|c}} key). Alternatively you can use the [[#Mutt-Sidebar|sidebar]].<br />
<br />
To change folder for different mailboxes you have to type the complete address -- for IMAP/POP3 folders, this may be quite inconvenient -- let us bind some key to it.<br />
<br />
{{bc|<br />
## Shortcuts<br />
macro index,pager <f2> '<sync-mailbox><enter-command>source ~/.mutt/personal<enter><change-folder>!<enter>'<br />
macro index,pager <f3> '<sync-mailbox><enter-command>source ~/.mutt/work<enter><change-folder>!<enter>'<br />
}}<br />
<br />
With the above shortcuts (or with the sidebar) you will find that changing folders (with {{ic|c}} by default) is not contextual, ''i.e.'' it will not list the folders of the current mailbox, but of the one used the last time you changed folders. To make the behaviour more contextual, the trick is to press ''='' or ''+'' for current mailbox. You can automate this with the following macro:<br />
macro index 'c' '<change-folder>?<change-dir><home>^K=<enter>'<br />
<br />
===Passwords management===<br />
Keep in mind that writing your password in {{ic|.muttrc}} is a security risk, and it might be of your concern.<br />
The trivial way to keep your passwords safe is not writing them in the config file. Mutt will then prompt for it when needed.<br />
However, this is quite cumbersome in the long run, especiallly if you have several accounts.<br />
<br />
Here follows a smart and convenient solution: all your passwords are encrypted into one file and Mutt will prompt for a passphrase on startup only. You can opt for a keyring tool (e.g. GPG, {{pkg|pwsafe}}) or an encryption tool like {{pkg|ccrypt}}, which may be more simple and straightforward to use.<br />
Since GPG is a Mutt dependency, we will use it here.<br />
<br />
First create a pair of public/private keys:<br />
gpg --gen-key<br />
If you do not understand this process have a look at [[Wikipedia:Asymmetric cryptography]].<br />
<br />
{{Expansion|What does "secure environment" mean?}}<br />
<br />
Create a file '''in a secure environment''' since it will contain your passwords for a couple of seconds:<br />
{{hc|~/.my-pwds|<nowiki><br />
set my_pw_personal = ****<br />
set my_pw_work = ****</nowiki><br />
}}<br />
<br />
{{Note|Remember that user defined variables '''must''' start with {{ic|my_}}.}}<br />
<br />
Now encrypt the file:<br />
gpg -e -r 'your-name' ~/.my-pwds<br />
Note that 'your-name' must match the one you provided at the {{ic|gpg --gen-key}} step.<br />
Now you can wipe your file containing your passwords in clear:<br />
shred -xu ~/.my-pwds<br />
Back to your account dedicated files, e.g. {{ic|.mutt/muttrc}}:<br />
{{bc|1=<br />
set imap_pass=$my_pw_personal<br />
# Every time the password is needed, use $my_pw_personal variable.<br />
}}<br />
<br />
And in your {{ic|.muttrc}}, '''before''' you source any account dedicated file:<br />
<br />
source "gpg2 -dq $HOME/.my-pwds.gpg |"<br />
<br />
{{Note|At the end of the line above, there is no space between the pipe and the double quote.}}<br />
* The {{ic|-q}} parameter makes gpg2 quiet which prevents gpg2 output messing with Mutt interface.<br />
* The pipe {{ic|<nowiki>|</nowiki>}} at the end of a string is the Mutt syntax to tell that you want the result of what is preceeding.<br />
<br />
Explanation: when Mutt starts, it will first source the result of the password decryption, that's why it will prompt for a passphrase. Then all passwords will be stored in memory in specific variables for the time Mutt runs. Then, when a folder-hook is called, it sets the imap_pass variable to the variable holding the appropriate password. When switching accounts, the imap_pass variable will be set to another variable holding another password, etc.<br />
<br />
If you use external tools like OfflineIMAP and msmtp, you need to set up an agent (e.g. gpg-agent, see [[GnuPG#gpg-agent]]) to keep the passphrase into cache and thus avoiding those tools always prompting for it.<br />
<br />
==== Security concern ====<br />
<br />
If {{ic|enter-command}} is available from the UI, it is possible to see the password unencrypted, which my be undesired if anybody else than you has access to your session while Mutt is running. You may want to disable it for this reason. As a consequence, every command that the user intends to use must be bound to a key in advance, otherwise it will never be accessible.<br />
{{hc|.muttrc|<br />
bind generic,alias,attach,browser,editor,index,compose,pager,pgp,postpone ':' noop<br />
}}<br />
<br />
==Advanced features==<br />
Guides to get you started with using & customizing Mutt : <br />
* [http://mutt.blackfish.org.uk/ My first Mutt] (maintained by Bruno Postle)<br />
* [http://www.therandymon.com/woodnotes/mutt/using-mutt.html The Woodnotes Guide to the Mutt Email Client] (maintained by Randall Wood)<br />
* [http://stevelosh.com/blog/2012/10/the-homely-mutt The Homely Mutt] (by Steve Losh)<br />
* [http://codesorcery.net/old/mutt/mutt-gnupg-howto Everything You Need To Know To Start Using GnuPG with Mutt] (by Justin R. Miller)<br />
<br />
If you have any Mutt specific questions, feel free to ask in [[ArchChannel|the irc channel]].<br />
<br />
===E-mail character encoding===<br />
You may be concerned with sending e-mail in a decent character set (charset for short) like UTF-8. Nowadays UTF-8 is highly recommended to almost everyone.<br />
<br />
When using Mutt there are two levels where the charset must be specified:<br />
* The text editor used to write the e-mail must save it in the desired encoding.<br />
* Mutt will then check the e-mail and determine which encoding is the more apropriate according to the priority you specified in the {{ic|send_charset}} variable. Default: "us-ascii:iso-8859-1:utf-8".<br />
<br />
So if you write an e-mail with characters allowed in ISO-8859-1 (like 'résumé'), but without characters specific to Unicode, then Mutt will set the encoding to ISO-8859-1.<br />
<br />
To avoid this behaviour, set the variable in your {{ic|muttrc}}:<br />
set send_charset="us-ascii:utf-8"<br />
or even<br />
set send_charset="utf-8"<br />
<br />
The first compatible charset starting from the left will be used.<br />
Since UTF-8 is a superset of US-ASCII it does not harm to leave it in front of UTF-8, it may ensure old MUA will not get confused when seeing the charset in the e-mail header.<br />
<br />
===Printing===<br />
You can install {{AUR|muttprint}} from the [[AUR]] for a fancier printing quality.<br />
In your muttrc file, insert:<br />
set print_command="/usr/bin/muttprint %s -p {PrinterName}"<br />
<br />
===Custom mail headers===<br />
One of the greatest thing in Mutt is that you can have full control over your mail header.<br />
<br />
First, make your headers editable when you write e-mails:<br />
set edit_headers=yes<br />
<br />
Mutt also features a special function {{ic|my_hdr}} for customizing your header. Yes, it is named just like a variable, but in fact it is a function.<br />
<br />
You can clear it completely, which you ''should'' do when switching accounts with different headers, otherwise they will overlap:<br />
unmy_hdr *<br />
<br />
Other variables have also an impact on the headers, so it is wise to clear them before using {{ic|my_hdr}}:<br />
unset use_from<br />
unset use_domain<br />
unset user_agent<br />
<br />
Now, you can add any field you want -- even non-standard one -- to your header using the following syntax:<br />
my_hdr <FIELD>: <VALUE><br />
Note that <VALUE> can be the result of a command.<br />
<br />
Example:<br />
{{bc|<br />
## Extra info.<br />
my_hdr X-Info: Keep It Simple, Stupid.<br />
<br />
## OS Info.<br />
my_hdr X-Operating-System: `uname -s`, kernel `uname -r`<br />
<br />
## This header only appears to MS Outlook users<br />
my_hdr X-Message-Flag: WARNING!! Outlook sucks<br />
<br />
## Custom Mail-User-Agent ID.<br />
my_hdr User-Agent: Every email client sucks, this one just sucks less.<br />
}}<br />
<br />
===Signature block===<br />
Create a .signature in your home directory. Your signature will be appended at the end of your email.<br />
Alternatively you can specify a file in your Mutt configuration:<br />
set signature="path/to/sig/file"<br />
====Random signature====<br />
You can use ''fortune'' (package {{Pkg|fortune-mod}}) to add a random signature to Mutt.<br />
<br />
Create a fortune file and then add the following line to your .muttrc:<br />
{{bc|1=set signature="fortune pathtofortunefile&#124;"}}<br />
Note the pipe at the end. It tells Mutt that the specified string is not a file, but a command.<br />
<br />
===Viewing URLs & opening your favorite web browser===<br />
Your should start by creating a .mutt directory in $HOME if not done yet. There, create a file named macros. Insert the following:<br />
macro pager \cb <pipe-entry>'urlview'<enter> 'Follow links with urlview'<br />
<br />
Then install {{AUR|urlview}} from the [[AUR]].<br />
<br />
Create a .urlview in $HOME and insert the following:<br />
REGEXP (((http|https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]<br />
COMMAND <your-browser> %s <br />
<br />
When you read an email on the pager, hitting ctrl+b will list all the urls from the email. Navigate up or down with arrow keys and hit enter on the desired url. Your browser will start and go to the selected site.<br />
<br />
Some browser will require additional arguments to work properly. For example, [[Luakit]] will close on Mutt exit. You need to fork it to background, using the {{ic|-n}} parameter:<br />
COMMAND luakit -n %s 2>/dev/null<br />
The {{ic|2>/dev/null}} is to make it quiet, i.e. to prevent useless message printing where you do not want them to.<br />
<br />
{{Note|urlview has a few deficiencies (e.g. the inability to handle certain email encodings) and is fairly feature-bare (e.g. it does not provide context for links it finds). There are a couple alternatives that do better. One, which can handle all email encodings and provides link context, is [http://www.memoryhole.net/~kyle/extract_url/ extract_url.pl]. Another, which can also provide link context but cannot handle all email encodings, is {{AUR|urlscan-git}}. Both are drop-in replacements for urlview, though extract_url has features which benefit from additional configuration changes.}}<br />
<br />
===Viewing HTML===<br />
It is possible to pass the html body to an external HTML program and then dump it, keeping email viewing uniform and unobtrusive. Three programs are described here: {{Pkg|lynx}}, {{Pkg|w3m}} and {{Pkg|elinks}} (make sure the selected package is [[pacman|installed]]).<br />
<br />
If {{ic|~/.mutt/mailcap}} does not exist you will need to create it and save the following to it.<br />
text/html; lynx -assume_charset=%{charset} -display_charset=utf-8 -dump %s; nametemplate=%s.html; copiousoutput<br />
or, in case of w3m,<br />
text/html; w3m -I %{charset} -T text/html; copiousoutput;<br />
or, in case of elinks,<br />
text/html; elinks -dump ; copiousoutput;<br />
<br />
Edit muttrc and add the following,<br />
set mailcap_path = ~/.mutt/mailcap<br />
<br />
To automatically open HTML messages in lynx, add this additional line to the muttrc:<br />
auto_view text/html<br />
<br />
The beauty of this is, instead of seeing an html body as source or being opened<br />
by a separate program, in this case lynx, you see the formatted content directly,<br />
and any url links within the email can be displayed with {{ic|Ctrl+b}}.<br />
<br />
If you receive many emails with multiple or alternate encodings Mutt may default to treating every email as html. To avoid this, add the following variable to your ~/.muttrc to have Mutt default to text when available and use w3m/lynx only when no text version is availble in the email:<br />
alternative_order text/plain text/html<br />
<br />
Some HTML mails may not display correctly in a text-based web browser. As a fallback solution, you can bind a key to open a graphical browser in such cases.<br />
The following macro will open the HTML mail selected from the attachment view in the web browser defined in the environment. (Feel free to adapt the {{ic|~/.cache/mutt/}} folder).<br />
macro attach 'V' "<pipe-entry>cat >~/.cache/mutt/mail.html && $BROWSER ~/.cache/mutt/mail.html && rm ~/.cache/mutt/mail.html<enter>"<br />
<br />
===Mutt and Vim===<br />
*To limit the width of text to 72 characters, edit your .[[vim]]rc file and add:<br />
au BufRead /tmp/mutt-* set tw=72<br />
<br />
*Another choice is to use Vim's mail filetype plugin to enable other mail-centric options besides 72 character width. Edit {{ic|~/.vim/filetype.vim}}, creating it if unpresent, and add:<br />
{{bc| <br />
augroup filetypedetect<br />
" Mail<br />
autocmd BufRead,BufNewFile *mutt-* setfiletype mail<br />
augroup END<br />
}}<br />
<br />
*To set a different tmp directory, e.g. ~/.tmp, add a line to your muttrc as follows:<br />
set tmpdir="~/.tmp"<br />
<br />
*To reformat a modified text see the Vim context help<br />
:h 10.7<br />
<br />
===Mutt and GNU nano===<br />
[[nano]] is another nice console editor to use with Mutt. <br />
<br />
To limit the width of text to 72 characters, edit your .nanorc file and add:<br />
set fill 72<br />
<br />
Also, in muttrc file, you can specify the line to start editing so that you will skip the mail header:<br />
set editor="nano +7"<br />
<br />
===Mutt and Emacs===<br />
Emacs has a ''mail'' and a ''message'' major mode.<br />
To switch to mail-mode automatically when Emacs is called from Mutt, you can add the following to your {{ic|.emacs}}:<br />
{{hc|.emacs|<nowiki><br />
;; Mutt support.<br />
(setq auto-mode-alist (append '(("/tmp/mutt.*" . mail-mode)) auto-mode-alist))<br />
</nowiki>}}<br />
<br />
If you usually run Emacs daemon, you may want Mutt to connect to it. Add this to your {{ic|.muttrc}}:<br />
{{hc|.muttrc|<nowiki><br />
set editor="emacsclient -a \"\" -t"</nowiki><br />
}}<br />
<br />
===Colors===<br />
Append sample color definitions to your .muttrc file:<br />
$ cat /usr/share/doc/mutt/samples/colors.linux >> ~/.muttrc<br />
Then adjust to your liking.<br />
The actual color each of these settings will produce depends on the colors set in your [[Xresources|~/.Xresources]] file.<br />
<br />
Alternatively, you can source any file you want containing colors (and thus act as a theme file):<br />
{{bc|<br />
source ~/.mutt/colors.zenburn<br />
}}<br />
<br />
A nice theme example:<br />
{{bc|<nowiki><br />
## Theme kindly inspired from <br />
## http://nongeekshandbook.blogspot.ie/2009/03/mutt-color-configuration.html <br />
<br />
## Colours for items in the index <br />
color index brightcyan black ~N<br />
color index brightred black ~O<br />
color index brightyellow black ~F<br />
color index black green ~T<br />
color index brightred black ~D<br />
mono index bold ~N<br />
mono index bold ~F<br />
mono index bold ~T<br />
mono index bold ~D<br />
<br />
## Highlights inside the body of a message. <br />
<br />
## URLs <br />
color body brightgreen black "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"<br />
color body brightgreen black "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"<br />
mono body bold "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"<br />
mono body bold "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"<br />
<br />
## Email addresses. <br />
color body brightgreen black "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"<br />
<br />
## Header <br />
color header green black "^from:"<br />
color header green black "^to:"<br />
color header green black "^cc:"<br />
color header green black "^date:"<br />
color header yellow black "^newsgroups:"<br />
color header yellow black "^reply-to:"<br />
color header brightcyan black "^subject:"<br />
color header red black "^x-spam-rule:"<br />
color header green black "^x-mailer:"<br />
color header yellow black "^message-id:"<br />
color header yellow black "^Organization:"<br />
color header yellow black "^Organisation:"<br />
color header yellow black "^User-Agent:"<br />
color header yellow black "^message-id: .*pine"<br />
color header yellow black "^X-Fnord:"<br />
color header yellow black "^X-WebTV-Stationery:"<br />
<br />
color header red black "^x-spam-rule:"<br />
color header green black "^x-mailer:"<br />
color header yellow black "^message-id:"<br />
color header yellow black "^Organization:"<br />
color header yellow black "^Organisation:"<br />
color header yellow black "^User-Agent:"<br />
color header yellow black "^message-id: .*pine"<br />
color header yellow black "^X-Fnord:"<br />
color header yellow black "^X-WebTV-Stationery:"<br />
color header yellow black "^X-Message-Flag:"<br />
color header yellow black "^X-Spam-Status:"<br />
color header yellow black "^X-SpamProbe:"<br />
color header red black "^X-SpamProbe: SPAM"<br />
<br />
## Coloring quoted text - coloring the first 7 levels: <br />
color quoted cyan black<br />
color quoted1 yellow black<br />
color quoted2 red black<br />
color quoted3 green black<br />
color quoted4 cyan black<br />
color quoted5 yellow black<br />
color quoted6 red black<br />
color quoted7 green black<br />
<br />
## Default color definitions <br />
#color hdrdefault white green <br />
color signature brightmagenta black<br />
color indicator black cyan<br />
color attachment black green<br />
color error red black<br />
color message white black<br />
color search brightwhite magenta<br />
color status brightyellow blue<br />
color tree brightblue black<br />
color normal white black<br />
color tilde green black<br />
color bold brightyellow black<br />
#color underline magenta black <br />
color markers brightcyan black<br />
<br />
## Colour definitions when on a mono screen <br />
mono bold bold<br />
mono underline underline<br />
mono indicator reverse</nowiki><br />
}}<br />
<br />
===Index Format===<br />
<br />
Here follows a quick example to put in your {{ic|.muttrc}} to customize the Index Format, i.e. the columns displayed in the folder view.<br />
{{bc|<nowiki><br />
set date_format="%y-%m-%d %T"<br />
set index_format="%2C | %Z [%d] %-30.30F (%-4.4c) %s"</nowiki><br />
}}<br />
See the [http://www.mutt.org/doc/manual/manual-6.html Mutt Reference], {{ic|man 3 strftime}} and {{ic|man 3 printf}} for more details.<br />
<br />
====Display recipient instead of sender in "Sent" folder view====<br />
<br />
By default Mutt will display the sender in the index view. It is fine for most folders, but rather useless for the one were you store a copy of your sent e-mails since it will always display your name.<br />
<br />
The "columns" of the index can be configured through the {{ic|index_format}} variable. Its syntax is documented in the {{ic|muttrc}} man page. The values of our concern are {{ic|%t}} (recipient) and {{ic|%F}} (sender).<br />
<br />
To change the columns according to the current folder, we need to use a hook:<br />
{{hc|muttrc|<nowiki><br />
folder-hook *[sS]ent* 'set index_format="%2C | %Z [%d] %-30.30t (%-4.4c) %s"'<br />
folder-hook ! *[sS]ent* 'set index_format="%2C | %Z [%d] %-30.30F (%-4.4c) %s"'<br />
</nowiki>}}<br />
<br />
The exclamation mark means ''everything that does not match the following regex''. Of course you can change the index_format following you taste, and the regular expression if the folder does not have ''Sent'' not ''sent'' in its name.<br />
<br />
====Variable column width====<br />
<br />
If you resize the window, the subject might get truncated while there is still unused space left for some fields, like for the sender.<br />
You can get the maximum number of columns supported by your terminal (i.e. the width) using a shell call to {{ic|tput cols}}. With this value, you can set a percentage of the width to fields like Sender and Subject.<br />
<br />
Example using the above folder-hook and a sidebar width of 24:<br />
{{hc|muttrc|<nowiki><br />
## From field gets 30% of remaining space, Subject gets 70%.<br />
## Remaining space is the total width minus the other fields (35), minus the sidebar (24)<br />
set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`<br />
set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`<br />
<br />
folder-hook .*[sS]ent.* 'set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}t (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
folder-hook ! .*[sS]ent.* 'set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}F (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
</nowiki><br />
}}<br />
<br />
Unfortunately, the above example suffers from one caveat: the {{ic|my_col_*}} variables get computed one time only, on first start. So if you want it to refresh automatically, we need to set the variable in a hook. Sadly there is no hook for window resizing, but you can still use the {{ic|folder-hook}} so that a simple folder switch suffices to recompute the view.<br />
{{hc|muttrc|<nowiki><br />
folder-hook .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`; set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}t (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
folder-hook ! .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`; set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}F (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
</nowiki><br />
}}<br />
<br />
===Contact management===<br />
<br />
====Address aliases====<br />
''Aliases'' is the way Mutt manages contacts.<br />
An alias is '''nickname [longname] <address>'''.<br />
* The '''nickname''' is what you will type in Mutt to get your contact address. One word only, and should be easy to remember.<br />
* The '''longname''' is optional. It may be several words.<br />
* An '''<address>''' must be in a valid form (i.e. with an {{ic|@}}).<br />
<br />
It is quite simple indeed. Add this to {{ic|.muttrc}}:<br />
{{bc|1=<br />
set alias_file = "~/.mutt/aliases"<br />
set sort_alias = alias<br />
set reverse_alias = yes<br />
source $alias_file<br />
}}<br />
<br />
Explanation:<br />
* {{ic|alias_file}} is the file where the information is getting stored when you add an alias from within Mutt.<br />
* {{ic|sort_alias}} specifies which field to use to sort the alias list when displayed in Mutt. Possible values: alias, address.<br />
* {{ic|reverse_alias}} sorts in reverse order if set to yes.<br />
* {{ic|source $alias_file}} tells Mutt to read aliases on startup. Needed for auto-completion.<br />
<br />
Now all you have to do when prompted {{ic|To:}} is writing the alias instead of the full address. The beauty of it is that you can auto-complete the alias using {{ic|Tab}}.<br />
Autocompleting a wrong or an empty string will display the full list. You can select the alias as usual, or by typing its index number.<br />
<br />
There are two ways to create aliases:<br />
* From Mutt, press {{ic|a}} when an e-mail of the targetted person if selected.<br />
* Edit the alias_file manually. The syntax is really simple:<br />
{{bc|<br />
alias nickname Long Name <my-friend@domain.tld><br />
}}<br />
<br />
====Abook====<br />
<br />
{{pkg|abook}} is a stand-alone program dedicated to contact management. It uses a very simple text-based interface and contacts are stored in a plain text, human-readable database. Besides the desired contact properties are extensible (birthday, address, fax, and so on).<br />
<br />
Abook is specifically designed to be interfaced with Mutt, so that it can serve as a full, more featured replacement of Mutt internal aliases. If you want to use Abook instead of aliases, remove the aliases configuration in {{ic|.muttrc}} and add this:<br />
<br />
{{hc|muttrc|<nowiki><br />
## Abook<br />
set query_command= "abook --mutt-query '%s'"<br />
macro index,pager a "<pipe-message>abook --add-email-quiet<return>" "Add this sender to Abook"<br />
bind editor <Tab> complete-query<br />
</nowiki><br />
}}<br />
<br />
See the man pages {{ic|abook}} and {{ic|abookrc}} for more details and a full configuration sample.<br />
<br />
===Goobook===<br />
<br />
Goobook allows you to search your Google contracts from the command line or from within Mutt. {{AUR|goobook-git}} can be installed from AUR. <br />
<br />
Before using goobook you must configure {{ic|~/.goobookrc}}. To generate the default template: <br />
$ goobook config-template > ~/.goobookrc<br />
<br />
See {{ic|~/.goobookrc}} for configuration options. At a minimum, you will need to enter your '''email''' and '''password'''.<br />
<br />
{{Note|If you have two-step verification enable with google you may need to generate an app password<br />
}}<br />
<br />
If you want to use Goobook instead of aliases, remove any alias configuration in {{ic|.muttrc}} and add:<br />
{{hc|muttrc|<nowiki><br />
## GooBook<br />
set query_command="goobook query '%s'"<br />
macro index,pager a "<pipe-message>goobook add<return>" "add sender to google contacts"<br />
bind editor <Tab> complete-query<br />
</nowiki><br />
}}<br />
<br />
When composing an email message within mutt, '''tab''' will now search your google contacts. While viewing messages '''a''' will add the sender to google contacts.<br />
<br />
===Request IMAP mail retrieval manually===<br />
If you do not want to wait for the next automatic IMAP fetching (or if you did not enable it), you might want to fetch mails manually.<br />
There is a mutt command {{ic|imap-fetch-mail}} for that.<br />
Alternatively, you could bind it to a key:<br />
bind index "^" imap-fetch-mail<br />
<br />
===Avoiding slow index on large (IMAP) folders due to coloring===<br />
<br />
Index highlighting by regex is nice, but can lead to slow folder viewing if your regex checks the body of the message.<br />
<br />
Use folder-hook for only highlighting in for example the inbox (if you manage to empty your mailbox effiently):<br />
<br />
folder-hook . 'uncolor index "~b \"Hi Joe\" ~R !~T !~F !~p !~P"'<br />
folder-hook ""!"" 'color index brightyellow black "~b \"Hi Joe\" ~N !~T !~F !~p !~P"'<br />
<br />
===Speed up folders switch===<br />
Add this to your {{ic|.muttrc}}:<br />
{{bc|1=<br />
set sleep_time = 0<br />
}}<br />
<br />
===Use Mutt to send mail from command line===<br />
Man pages will show all available commands and how to use them, but here are a couple of examples. You could use Mutt to send alerts, logs or some other system information, triggered by login through .bash_profile, or as a regular cron job.<br />
<br />
Send a message:<br />
mutt -s "Subject" somejoeorjane@someserver.com < /var/log/somelog<br />
<br />
Send a message with attachment:<br />
mutt -s "Subject" somejoeorjane@someserver.com -a somefile < /tmp/sometext.txt<br />
<br />
===Composing HTML e-mails===<br />
<br />
Since Mutt has nothing of a WYSIWIG client, HTML is quite straightforward, and you can do much more than with all WYSIWIG mail clients around since you edit the source code directly.<br />
Simply write your mail using HTML syntax. For example:<br />
{{bc|<nowiki><br />
This is normal text<br><br />
<b>This is bold text</b></nowiki><br />
}}<br />
Now before sending the mail, use the {{ic|edit-type}} command (default shortcut {{ic|Ctrl+t}}), and replace {{ic|text/plain}} by {{ic|text/html}}.<br />
<br />
{{Note|HTML e-mails are regarded by many people as useless, cumbersome, and subject to reading issues. Mutt can read HTML mails with a text browser like w3m or lynx, but it has clearly no advantage over a plain-text e-mail. You should avoid writing HTML e-mails when possible.}}<br />
<br />
===How to display another email while composing===<br />
A common complaint with Mutt is that when composing a new mail (or reply), you cannot open another mail (i.e. for checking with another correspondent) without closing the current mail (postponing). The following describes a solution:<br />
<br />
First, fire up Mutt as usual. Then, launch another terminal window. Now start a new Mutt with <br />
mutt -R<br />
This starts Mutt in read-only mode, and you can browse other emails at your convenience. It is strongly recommended to always launch a second Mutt in read-only mode, as conflicts will easily arise otherwise.<br />
<br />
{{Note|When changing folders (with {{ic|c}} or {{ic|y}}) the read-only mode is not preserved. Instead {{ic|Esc c}} has to be used.}}<br />
<br />
{{Tip|This solution calls for a bit of typing, so it is suitable to bind the following command to a keyboard shortcut (see [[Extra Keyboard Keys]] for details):<br />
$TERMINAL -e mutt -R <br />
where {{ic|$TERMINAL}} is your terminal.}}<br />
<br />
===Archive treated e-mails===<br />
When you read an e-mail, you have four choices: Answer it, Flag it, Archive it or Delete it. If you have this in mind, you can keep your inbox slim and fit with this macro (set up for Gmail):<br />
<br />
macro index \' "<tag-pattern>~R !~D !~F<enter>\<br />
<tag-prefix><save-message>+[Gmail]/All <enter>" \<br />
"Archive"<br />
<br />
===Mutt-Sidebar===<br />
<br />
The vanilla Mutt does not feature a sidebar unlike most MUAs. If you miss it, you can install {{AUR|mutt-sidebar}} from the AUR which features a patch for a list of folders on the left side of the Mutt window.<br />
<br />
For a while there has been several different patches for the sidebar. Since the late 2000's, it seems like the main patch is maintained at [http://www.lunar-linux.org/mutt-sidebar/ Lunar Linux]. See the documentation there. Note that the patch also updates the {{ic|muttrc}} man page, so have a look at the {{ic|sidebar_*}} sections.<br />
<br />
You can choose to display the sidebar on startup, or to prompt it manually with a key:<br />
{{bc|<nowiki><br />
set sidebar_visible = yes<br />
macro index b '<enter-command>toggle sidebar_visible<enter><refresh>'<br />
macro pager b '<enter-command>toggle sidebar_visible<enter><redraw-screen>'<br />
</nowiki>}}<br />
<br />
You also probabaly need some shortcuts to navigate in the bar:<br />
{{bc|<nowiki><br />
# Ctrl-n, Ctrl-p to select next, previous folder.<br />
# Ctrl-o to open selected folder.<br />
bind index,pager \CP sidebar-prev<br />
bind index,pager \CN sidebar-next<br />
bind index,pager \CO sidebar-open<br />
</nowiki>}}<br />
<br />
{{Note|You ''must'' set the {{ic|mailboxes}} variables or the {{ic|imap_check_subscribed}} to tell the sidebar which folder should be displayed. See the [[#mailboxes|mailboxes]] section.}}<br />
<br />
If you use the {{ic|imap_check_subscribed}} option to list all your folders, they will appear in an uncontrollable order in the sidebar. Fix it with<br />
set sidebar_sort = yes<br />
Note that with the {{ic|mailboxes}} option, folders appear in the order they were set to {{ic|mailboxes}} if you do not use the {{ic|sidebar_sort}} option.<br />
<br />
If you have trouble with truncated names, set the option<br />
set sidebar_shortpath = yes<br />
<br />
Finally, you may want to add a separator between different mailboxes. The sidebar patch does not currently provide any kind of separator option. A simple (and dirty) workaround is to add a fake folder to the list of folders:<br />
mailboxes "+-- My mailbox -----------"<br />
The dashes are not required, they are here just for fancy output.<br />
It will also work if you used the {{ic|imap_check_subscribed}} option.<br />
If you chose to sort the folders, the separator will not appear in the correct place, so an even more dirty workaround is to add an 'A' in front of the name. Note that punctuation is ignored during sorting.<br />
mailboxes "+A-- My mailbox -----------"<br />
<br />
===Migrating mails from one computer to another===<br />
In case you are transfering your mails to a new machine (copy&paste), you probably need to delete the header cache (a file or folder like {{ic|~/.cache/mutt}} if you followed the above configuration) to make Mutt able to read your migrated E-Mails. Otherwise Mutt may freeze.<br />
<br />
Note that if you had a folder created for you header cache, all mailboxes will have their own cache file, so you can delete caches individually without having to remove everything.<br />
<br />
=== Filtering the message view ===<br />
<br />
You can restrict the view to e-mails matching a pattern and specific properties with the {{ic|limit}} command (default shortcut: {{ic|l}}).<br />
<br />
To view all e-mails containing "foo" in the header, simply write "foo" and you are done. To remove the filter, use the "all" keyword.<br />
<br />
To view all flagged messages, use<br />
~F<br />
To view all unread messages, use<br />
~U<br />
<br />
All possible patterns are listed in the [http://www.mutt.org/doc/manual/manual-4.html#ss4.2 official manual].<br />
<br />
=== Display the index above the pager view ===<br />
<br />
Set the following variable in your {{ic|muttrc}}:<br />
set pager_index_lines=10<br />
<br />
==Troubleshooting==<br />
<br />
===Backspace does not work in Mutt===<br />
This is a common problem with some xterm-like terminals.<br />
Two solutions:<br />
* Either rebind the key in {{ic|.muttrc}}<br />
bind index,pager ^? previous-line<br />
Note that {{ic|^?}} is one single character representing backspace in [[wikipedia:Caret_notation|caret notation]]. To type in Emacs, use {{ic|Ctrl+q Backspace}}, in Vim {{ic|Ctrl+v Backspace}}.<br />
<br />
* Or fix your terminal:<br />
$ infocmp > termbs.src<br />
Edit {{ic|termbs.src}} and change {{ic|1= kbs=^H}} to {{ic|1= kbs=\177}}, then:<br />
$ tic -x termbs.src<br />
<br />
===Android's default MUA receives empty e-mail with attachment "Unknown.txt"===<br />
<br />
This is because Mutt adds 'Content-Disposition' line to every e-mail header. This line is actually correct, the issue comes from Android 2 MUA misinterpreting it. This bug seems to be fixed in the Android 4 MUA.<br />
There is a patched version for Android available in the AUR. Installing {{AUR|mutt-android-patch}} will fix the issue.<br />
<br />
===The ''change-folder'' function always prompt for the same mailbox ===<br />
<br />
This is not a bug, this is actually an intended behaviour. See the [[#Multiple accounts|multiple accounts section]] for a workaround.<br />
<br />
===I cannot change folder when using Mutt read-only (Mutt -R)===<br />
<br />
This is certainly because you are using macros like this one:<br />
macro index,pager <f2> '<sync-mailbox><enter-command>source ~/.mutt/personal<enter><change-folder>!<enter>'<br />
This macro tells Mutt to sync (which is a write operation) before switching.<br />
Either use the [[#Mutt-Sidebar|sidebar]] or set another macro:<br />
macro index,pager <f3> '<enter-command>source ~/.mutt/personal<enter><change-folder>!<enter>'<br />
<br />
===Error sending message, child exited 127 (Exec error.).===<br />
This is an SMTP error. It means that mutt does not know how to send the message.<br />
You can either try installing sendmail and see if that solves your issue, or you can set the smtp_url variable. If you use gmail, you can add the following to your muttrc to tell mutt to use gmails smtp server.<br />
<br />
set smtp_url=smtps://$imap_user:$imap_pass@smtp.gmail.com<br />
<br />
Take note of the smtps protocol, it is important.<br />
This should solve the problem.<br />
<br />
== Documentation ==<br />
<br />
Newcomers may find it quite hard to find help for Mutt. Actually most of the topics are covered in the official documentation. We urge you to read it.<br />
<br />
* [http://www.mutt.org/doc/manual/ The official manual]. The stock {{pkg|mutt}} package for Arch Linux also installs the HTML and plain text manual at {{ic|/usr/share/doc/mutt/}}.<br />
* The {{ic|mutt}} and {{ic|muttrc}} man pages.<br />
<br />
== See also ==<br />
* [http://www.mutt.org/ The official Mutt website]<br />
* [http://wiki.mutt.org/ The Mutt wiki]<br />
* [http://pbrisbin.com/posts/two_accounts_in_mutt/ Brisbin's great guide on how to setup different IMAP accounts with Mutt, offlineimap, msmtp]<br />
* [http://srobb.net/mutt.html A Quick Guide to Mutt]<br />
* [http://stevelosh.com/blog/2012/10/the-homely-mutt/ Steve Losh on Mutt, offlineimap, msmtp, notmuch (focused on Gmail)]<br />
* [http://www.muttrcbuilder.org/ muttrc builder]</div>Paris3200https://wiki.archlinux.org/index.php?title=Mutt&diff=367333Mutt2015-03-27T01:12:32Z<p>Paris3200: /* Native SMTP support */ Removed broken link for online version of man 5 muttrc</p>
<hr />
<div>[[Category:Email clients]]<br />
[[es:Mutt]]<br />
[[it:Mutt]]<br />
[[zh-CN:Mutt]]<br />
[[zh-TW:Mutt]]<br />
{{Related articles start}}<br />
{{Related|fdm}}<br />
{{Related|msmtp}}<br />
{{Related|offlineimap}}<br />
{{Related|isync}}<br />
{{Related articles end}}<br />
'''Mutt''' is a text-based mail client renowned for its powerful features. Though over a decade old, Mutt remains the mail client of choice for a great number of power-users. Unfortunately, a default Mutt install is plagued by complex keybindings along with a daunting amount of documentation. This guide will help the average user get Mutt up and running, and begin customizing it to their particular needs.<br />
<br />
==Overview==<br />
Mutt focuses primarily on being a Mail User Agent (MUA), and was originally written to view mail. Later implementations (added for retrieval, sending, and filtering mail) are simplistic compared to other mail applications and, as such, users may wish to use external applications to extend Mutt's capabilities. <br />
<br />
Nevertheless, the Arch Linux {{Pkg|mutt}} package is compiled with IMAP, POP3 and SMTP support, removing the necessity for external applications.<br />
<br />
This article covers using both native IMAP sending and retrieval, and a setup depending on [[OfflineIMAP]] or [[getmail]] (POP3) to retrieve mail, [[procmail]] to filter it in the case of POP3, and [[msmtp]] to send it.<br />
<br />
==Installing==<br />
[[pacman|Install]] {{Pkg|mutt}}, available in the [[official repositories]]. <br />
<br />
Optionally install external helper applications for an IMAP setup, such as [[isync]], [[OfflineIMAP]], or [[msmtp]].<br />
<br />
Or (if using POP3) {{Pkg|getmail}}, {{Pkg|fetchmail}} or {{Pkg|fdm}} and {{Pkg|procmail}}.<br />
<br />
{{Note|<br />
*If you just need the authentication methods LOGIN and PLAIN, these are satisfied with the dependency {{Pkg|libsasl}}<br />
*If you want to (or have to) use CRAM-MD5, GSSAPI or DIGEST-MD5, install the package {{Pkg|cyrus-sasl-gssapi}}<br />
*If you are using Gmail as your SMTP server, you may need to install the package {{Pkg|cyrus-sasl}}<br />
}}<br />
<br />
==Configuring==<br />
This section covers [[#IMAP]], [[#POP3]], [[#Maildir]] and [[#SMTP]] configuration.<br />
<br />
Note that Mutt will recognize by default two locations for its configuration file; {{ic|~/.muttrc}} and {{ic|~/.mutt/muttrc}}. Either location will work. In case you decide to put the initialization file somewhere else, use {{ic|$ mutt -F /path/to/.muttrc}}.<br />
You should also know some prerequisite for Mutt configuration. Its syntax is very close to the Bourne Shell. For example, you can get the content of another config file:<br />
source /path/to/other/config/file<br />
You can use variables and assign the result of shell commands to them.<br />
set editor=`echo \$EDITOR`<br />
Here the {{ic|$}} gets escaped so that it does not get substituted by Mutt before being passed to the shell.<br />
Also note the use of the backquotes, as bash syntax {{ic|$(...)}} does not work.<br />
Mutt has a lot of predefined variables, but you can also set your own. User variable '''must begin with "my"!'''<br />
set my_name = "John Doe"<br />
<br />
===IMAP===<br />
<br />
====Native IMAP support====<br />
The pacman version of Mutt is compiled with IMAP support. At the very least you need to have 4 lines in your muttrc file to be able to access your mail.<br />
<br />
=====imap_user=====<br />
set imap_user=USERNAME<br />
<br />
{{Tip|Continuing with the previous example, remember that Gmail requires your full email address (this is not standard): {{bc|1=set imap_user=your.username@gmail.com}}}}<br />
<br />
=====imap_pass=====<br />
If unset, the password will be prompted for.<br />
set imap_pass=SECRET<br />
<br />
{{Tip|If you have enabled two-factor authentication in Gmail and you have added an application specific password for Mutt, you will want to use that password here rather than your regular Gmail password.}}<br />
<br />
=====folder=====<br />
Instead of a local directory which contains all your mail (and directories), use your server (and the highest folder in the hierarchy, if needed).<br />
set folder=imap[s]://imap.server.domain[:port]/[folder/]<br />
<br />
You do not have to use a folder, but it might be convenient if you have all your other folders inside your INBOX, for example. Whatever you set here as your folder can be accessed later in Mutt with just an equal sign (=) or a plus sign (+). Example:<br />
set folder=imaps://imap.gmail.com/<br />
<br />
It should be noted that for several accounts, it is best practice to use different folders -- e.g. for ''account-hook''. If you have several Gmail account, use<br />
set folder=imaps://username@imap.gmail.com/<br />
instead, where your account is ''username@gmail.com''. This way it will be possible to distinguish the different folders. Otherwise it would lead to authentication errors.<br />
<br />
=====spoolfile=====<br />
The spoolfile is the folder where your (unfiltered) e-mail arrives. Most e-mail services conventionally names it ''INBOX''. You can now use '=' or '+' as a substitution for the full {{ic|folder}} path that was configured above. For example:<br />
set spoolfile=+INBOX<br />
<br />
=====mailboxes=====<br />
Any imap folders that should be checked regularly for new mail should be listed here:<br />
mailboxes =INBOX =family<br />
mailboxes imaps://imap.gmail.com/INBOX imaps://imap.gmail.com/family<br />
<br />
Alternatively, check for all subscribed IMAP folders (as if all were added with a {{Ic|mailboxes}} line):<br />
set imap_check_subscribed<br />
<br />
These two versions are equivalent if you want to subscribe to all folders. So the second method is much more convenient, but the first one gives you more flexibility. Also, newer Mutt versions are configured by default to include a macro bound to the 'y' key which will allow you to change to any of the folders listed under mailboxes.<br />
<br />
If you do not set this variable, the ''spoolfile'' will be used by default.<br />
This variable is also important for the [[#Mutt-Sidebar|sidebar]].<br />
<br />
=====Summary=====<br />
Using these options, you will be able to start Mutt, enter your IMAP password, and start reading your mail. Here is a muttrc snippet (for Gmail) with some other lines you might consider adding for better IMAP support.<br />
{{bc|1=<br />
set folder = imaps://imap.gmail.com/<br />
set imap_user = your.username@gmail.com<br />
set imap_pass = your-imap-password<br />
set spoolfile = +INBOX<br />
mailboxes = +INBOX<br />
<br />
# Store message headers locally to speed things up.<br />
# If hcache is a folder, Mutt will create sub cache folders for each account which may speeds things up even more.<br />
set header_cache = ~/.cache/mutt<br />
<br />
# Store messages locally to speed things up, like searching message bodies.<br />
# Can be the same folder as header_cache.<br />
# This will cost important disk usage according to your e-mail amount.<br />
set message_cachedir = "~/.cache/mutt"<br />
<br />
# Specify where to save and/or look for postponed messages.<br />
set postponed = +[Gmail]/Drafts<br />
<br />
# Allow Mutt to open new imap connection automatically.<br />
unset imap_passive<br />
<br />
# Keep IMAP connection alive by polling intermittently (time in seconds).<br />
set imap_keepalive = 300<br />
<br />
# How often to check for new mail (time in seconds).<br />
set mail_check = 120<br />
}}<br />
<br />
====External IMAP support====<br />
While IMAP support is built into Mutt, it does not download mail for offline use. It is possible to use an external application such as [[OfflineIMAP]] or [[isync]] to download your emails to a local folder which can then be processed by Mutt.<br />
<br />
Consider using applications such as {{pkg|spamassassin}} or {{AUR|imapfilter}} to sort mail.<br />
<br />
===POP3===<br />
One popular option is to use [[getmail]] for retrieving and [[procmail]] for filtering the mail.<br />
<br />
===Maildir===<br />
Maildir is a generic and standardized format. Almost every MUA is able to handle Maildirs and Mutt's support is excellent. There are just a few simple things that you need to do to get Mutt to use them. Open your muttrc and add the following lines:<br />
{{bc|1=<br />
set mbox_type=Maildir<br />
set folder=$HOME/mail<br />
set spoolfile=+/<br />
set header_cache=~/.cache/mutt<br />
}}<br />
<br />
This is a minimal Configuration that enables you to access your Maildir and checks for new local Mails in INBOX. This configuration also caches the headers of the eMails to speed up directory-listings. It might not be enabled in your build (but it sure is in the Arch-Package). Note that this does not affect OfflineIMAP in any way. It always syncs the all directories on a Server. {{ic|spoolfile}} tells Mutt which local directories to poll for new Mail. You might want to add more Spoolfiles (for example the Directories of Mailing-Lists) and maybe other things. But this is subject to the Mutt manual and beyond the scope of this document.<br />
<br />
===SMTP===<br />
Whether you use POP or IMAP to receive mail you will probably still send mail using SMTP.<br />
<br />
==== Folders ====<br />
<br />
There is basically only one important folder here: the one where all your sent e-mails will be saved.<br />
set record = +Sent<br />
<br />
Gmail saves automatically sent e-mail to {{ic|+[Gmail]/Sent}}, so we do not want<br />
duplicates.<br />
unset record<br />
<br />
====Native SMTP support====<br />
The official {{Pkg|mutt}} is also compiled with SMTP support.<br />
<br />
For example:<br />
{{bc|1=<br />
set my_pass='mysecretpass'<br />
set my_user=myname<br />
<br />
set realname = 'Your Real Name'<br />
set from = your-email-address<br />
set use_from = yes<br />
<br />
set smtp_url=smtps://$my_user:$my_pass@smtp.domain.tld<br />
set ssl_force_tls = yes<br />
}}<br />
<br />
Note that if your SMTP credentials are the same as your IMAP credentials, then you can use those variables:<br />
<br />
{{bc|1=<br />
set smtp_url=smtps://$imap_user:$imap_pass@smtp.domain.tld<br />
}}<br />
<br />
You may need to tweak the security parameters. If you get an error like<br />
{{ic|SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol}},<br />
then your server probably uses the SMTP instead of SMTPS.<br />
<br />
{{bc|1=<br />
set smtp_url=smtp://$imap_user:$imap_pass@smtp.domain.tld<br />
}}<br />
<br />
There are other variables that you may need to set. For example for use of STARTTLS:<br />
{{bc|1=<br />
set ssl_starttls = yes<br />
}}<br />
<br />
See {{ic|man 5 muttrc}} for more information.<br />
<br />
====External SMTP support====<br />
<br />
An external SMTP agent such as [[msmtp]], [[SSMTP]] or {{Pkg|opensmtpd}} can also be used.<br />
<br />
The {{ic|sendmail}} variable in your {{ic|muttrc}} determines the program and arguments used to deliver mail in mutt. Any additional arguments must be interpreted by the program as recipient addresses.<br />
<br />
For example, if using [[msmtp]]:<br />
<br />
{{hc|muttrc|2=<br />
set realname='Disgruntled Kangaroo'<br />
<br />
set sendmail="/usr/bin/msmtp"<br />
<br />
set edit_headers=yes<br />
set folder=~/mail<br />
set mbox=+mbox<br />
set spoolfile=+inbox<br />
set record=+sent<br />
set postponed=+drafts<br />
set mbox_type=Maildir<br />
<br />
mailboxes +inbox +lovey-dovey +happy-kangaroos<br />
}}<br />
<br />
====Sending mails from Mutt====<br />
Now, startup {{Ic|mutt}}:<br />
<br />
You should see all the mail in {{ic|~/mail/inbox}}. Press {{ic|m}} to compose mail; it will use the editor defined by your {{Ic|EDITOR}} environment variable. If this variable is not set, you can fix it before starting Mutt:<br />
$ export EDITOR=your-favorite-editor<br />
$ mutt<br />
<br />
You should store the EDITOR value into your shell resource configuration file (such as [[bashrc]]).<br />
You can also set the editor from Mutt's configuration file:<br />
{{hc|.muttrc|2=<br />
set editor=your-favorite-editor<br />
}}<br />
<br />
For testing purposes, address the letter to yourself. After you have written the letter, save and exit the editor. You will return to Mutt, which will now show information about your e-mail. Press {{ic|y}} to send it.<br />
<br />
===Multiple accounts===<br />
<br />
Now you should have a working configuration for one account at least. You might wonder how to use several accounts, since we put everything into a single file.<br />
<br />
Well all you need is to write account-specific parameters to their respective files and source them. All the IMAP/POP3/SMTP config for each account should go to its respective folder.<br />
{{Warning|When one account is setting a variable that is not specified for other accounts, you '''must unset''' it for them, otherwise configuration will overlap and you will most certainly experience unexpected behaviour.}}<br />
<br />
Mutt can handle this thanks to one of its most powerful features: hooks.<br />
Basically a hook is a command that gets executed before a specific action.<br />
There are several hooks available. For multiple accounts, you must use account-hooks ''and'' folder-hooks.<br />
* Folder-hooks will run a command before switching folders. This is mostly useful to set the appropriate SMTP parameters when you are in a specific folder. For instance when you are in your work mailbox and you send a e-mail, it will automatically use your work account as sender.<br />
* Account-hooks will run a command everytime Mutt calls a function related to an account, like IMAP syncing. It does not require you to switch to any folder.<br />
<br />
Hooks take two parameters:<br />
account-hook [!]regex command<br />
folder-hook [!]regex command<br />
The regex is the folder to be matched (or not if preceded by the !).<br />
The command tells what to do.<br />
<br />
Let us give a full example:<br />
<br />
{{hc|.muttrc|<nowiki><br />
## General options<br />
set header_cache = "~/.cache/mutt"<br />
set imap_check_subscribed<br />
set imap_keepalive = 300<br />
unset imap_passive<br />
set mail_check = 60<br />
set mbox_type=Maildir<br />
<br />
## ACCOUNT1<br />
source "~/.mutt/work"<br />
# Here we use the $folder variable that has just been set in the sourced file.<br />
# We must set it right now otherwise the 'folder' variable will change in the next sourced file.<br />
folder-hook $folder 'source ~/.mutt/work'<br />
<br />
## ACCOUNT2<br />
source "~/.mutt/personal"<br />
folder-hook *user@gmail.com/ 'source ~/.mutt/personal'<br />
folder-hook *user@gmail.com/Family 'set realname="Bob"'<br />
</nowiki>}}<br />
<br />
{{hc|.mutt/work|<nowiki><br />
## Receive options.<br />
set imap_user=user@gmail.com<br />
set imap_pass=****<br />
set folder = imaps://user@imap.gmail.com/<br />
set spoolfile = +INBOX<br />
set postponed = +Drafts<br />
set record = +Sent<br />
<br />
## Send options.<br />
set smtp_url=smtps://user:****@smtp.gmail.com<br />
set realname='User X'<br />
set from=user@gmail.com<br />
set hostname="gmail.com"<br />
set signature="John Doe"<br />
# Connection options<br />
set ssl_force_tls = yes<br />
unset ssl_starttls<br />
<br />
## Hook -- IMPORTANT!<br />
account-hook $folder "set imap_user=user@gmail.com imap_pass=****"<br />
</nowiki>}}<br />
<br />
Finally {{ic|.mutt/personal}} should be similar to {{ic|.mutt/work}}.<br />
<br />
Now all your accounts are set, start Mutt. To switch from one account to another, just change the folder ({{ic|c}} key). Alternatively you can use the [[#Mutt-Sidebar|sidebar]].<br />
<br />
To change folder for different mailboxes you have to type the complete address -- for IMAP/POP3 folders, this may be quite inconvenient -- let us bind some key to it.<br />
<br />
{{bc|<br />
## Shortcuts<br />
macro index,pager <f2> '<sync-mailbox><enter-command>source ~/.mutt/personal<enter><change-folder>!<enter>'<br />
macro index,pager <f3> '<sync-mailbox><enter-command>source ~/.mutt/work<enter><change-folder>!<enter>'<br />
}}<br />
<br />
With the above shortcuts (or with the sidebar) you will find that changing folders (with {{ic|c}} by default) is not contextual, ''i.e.'' it will not list the folders of the current mailbox, but of the one used the last time you changed folders. To make the behaviour more contextual, the trick is to press ''='' or ''+'' for current mailbox. You can automate this with the following macro:<br />
macro index 'c' '<change-folder>?<change-dir><home>^K=<enter>'<br />
<br />
===Passwords management===<br />
Keep in mind that writing your password in {{ic|.muttrc}} is a security risk, and it might be of your concern.<br />
The trivial way to keep your passwords safe is not writing them in the config file. Mutt will then prompt for it when needed.<br />
However, this is quite cumbersome in the long run, especiallly if you have several accounts.<br />
<br />
Here follows a smart and convenient solution: all your passwords are encrypted into one file and Mutt will prompt for a passphrase on startup only. You can opt for a keyring tool (e.g. GPG, {{pkg|pwsafe}}) or an encryption tool like {{pkg|ccrypt}}, which may be more simple and straightforward to use.<br />
Since GPG is a Mutt dependency, we will use it here.<br />
<br />
First create a pair of public/private keys:<br />
gpg --gen-key<br />
If you do not understand this process have a look at [[Wikipedia:Asymmetric cryptography]].<br />
<br />
{{Expansion|What does "secure environment" mean?}}<br />
<br />
Create a file '''in a secure environment''' since it will contain your passwords for a couple of seconds:<br />
{{hc|~/.my-pwds|<nowiki><br />
set my_pw_personal = ****<br />
set my_pw_work = ****</nowiki><br />
}}<br />
<br />
{{Note|Remember that user defined variables '''must''' start with {{ic|my_}}.}}<br />
<br />
Now encrypt the file:<br />
gpg -e -r 'your-name' ~/.my-pwds<br />
Note that 'your-name' must match the one you provided at the {{ic|gpg --gen-key}} step.<br />
Now you can wipe your file containing your passwords in clear:<br />
shred -xu ~/.my-pwds<br />
Back to your account dedicated files, e.g. {{ic|.mutt/muttrc}}:<br />
{{bc|1=<br />
set imap_pass=$my_pw_personal<br />
# Every time the password is needed, use $my_pw_personal variable.<br />
}}<br />
<br />
And in your {{ic|.muttrc}}, '''before''' you source any account dedicated file:<br />
<br />
source "gpg2 -dq $HOME/.my-pwds.gpg |"<br />
<br />
{{Note|At the end of the line above, there is no space between the pipe and the double quote.}}<br />
* The {{ic|-q}} parameter makes gpg2 quiet which prevents gpg2 output messing with Mutt interface.<br />
* The pipe {{ic|<nowiki>|</nowiki>}} at the end of a string is the Mutt syntax to tell that you want the result of what is preceeding.<br />
<br />
Explanation: when Mutt starts, it will first source the result of the password decryption, that's why it will prompt for a passphrase. Then all passwords will be stored in memory in specific variables for the time Mutt runs. Then, when a folder-hook is called, it sets the imap_pass variable to the variable holding the appropriate password. When switching accounts, the imap_pass variable will be set to another variable holding another password, etc.<br />
<br />
If you use external tools like OfflineIMAP and msmtp, you need to set up an agent (e.g. gpg-agent, see [[GnuPG#gpg-agent]]) to keep the passphrase into cache and thus avoiding those tools always prompting for it.<br />
<br />
==== Security concern ====<br />
<br />
If {{ic|enter-command}} is available from the UI, it is possible to see the password unencrypted, which my be undesired if anybody else than you has access to your session while Mutt is running. You may want to disable it for this reason. As a consequence, every command that the user intends to use must be bound to a key in advance, otherwise it will never be accessible.<br />
{{hc|.muttrc|<br />
bind generic,alias,attach,browser,editor,index,compose,pager,pgp,postpone ':' noop<br />
}}<br />
<br />
==Advanced features==<br />
Guides to get you started with using & customizing Mutt : <br />
* [http://mutt.blackfish.org.uk/ My first Mutt] (maintained by Bruno Postle)<br />
* [http://www.therandymon.com/woodnotes/mutt/using-mutt.html The Woodnotes Guide to the Mutt Email Client] (maintained by Randall Wood)<br />
* [http://stevelosh.com/blog/2012/10/the-homely-mutt The Homely Mutt] (by Steve Losh)<br />
* [http://codesorcery.net/old/mutt/mutt-gnupg-howto Everything You Need To Know To Start Using GnuPG with Mutt] (by Justin R. Miller)<br />
<br />
If you have any Mutt specific questions, feel free to ask in [[ArchChannel|the irc channel]].<br />
<br />
===E-mail character encoding===<br />
You may be concerned with sending e-mail in a decent character set (charset for short) like UTF-8. Nowadays UTF-8 is highly recommended to almost everyone.<br />
<br />
When using Mutt there are two levels where the charset must be specified:<br />
* The text editor used to write the e-mail must save it in the desired encoding.<br />
* Mutt will then check the e-mail and determine which encoding is the more apropriate according to the priority you specified in the {{ic|send_charset}} variable. Default: "us-ascii:iso-8859-1:utf-8".<br />
<br />
So if you write an e-mail with characters allowed in ISO-8859-1 (like 'résumé'), but without characters specific to Unicode, then Mutt will set the encoding to ISO-8859-1.<br />
<br />
To avoid this behaviour, set the variable in your {{ic|muttrc}}:<br />
set send_charset="us-ascii:utf-8"<br />
or even<br />
set send_charset="utf-8"<br />
<br />
The first compatible charset starting from the left will be used.<br />
Since UTF-8 is a superset of US-ASCII it does not harm to leave it in front of UTF-8, it may ensure old MUA will not get confused when seeing the charset in the e-mail header.<br />
<br />
===Printing===<br />
You can install {{AUR|muttprint}} from the [[AUR]] for a fancier printing quality.<br />
In your muttrc file, insert:<br />
set print_command="/usr/bin/muttprint %s -p {PrinterName}"<br />
<br />
===Custom mail headers===<br />
One of the greatest thing in Mutt is that you can have full control over your mail header.<br />
<br />
First, make your headers editable when you write e-mails:<br />
set edit_headers=yes<br />
<br />
Mutt also features a special function {{ic|my_hdr}} for customizing your header. Yes, it is named just like a variable, but in fact it is a function.<br />
<br />
You can clear it completely, which you ''should'' do when switching accounts with different headers, otherwise they will overlap:<br />
unmy_hdr *<br />
<br />
Other variables have also an impact on the headers, so it is wise to clear them before using {{ic|my_hdr}}:<br />
unset use_from<br />
unset use_domain<br />
unset user_agent<br />
<br />
Now, you can add any field you want -- even non-standard one -- to your header using the following syntax:<br />
my_hdr <FIELD>: <VALUE><br />
Note that <VALUE> can be the result of a command.<br />
<br />
Example:<br />
{{bc|<br />
## Extra info.<br />
my_hdr X-Info: Keep It Simple, Stupid.<br />
<br />
## OS Info.<br />
my_hdr X-Operating-System: `uname -s`, kernel `uname -r`<br />
<br />
## This header only appears to MS Outlook users<br />
my_hdr X-Message-Flag: WARNING!! Outlook sucks<br />
<br />
## Custom Mail-User-Agent ID.<br />
my_hdr User-Agent: Every email client sucks, this one just sucks less.<br />
}}<br />
<br />
===Signature block===<br />
Create a .signature in your home directory. Your signature will be appended at the end of your email.<br />
Alternatively you can specify a file in your Mutt configuration:<br />
set signature="path/to/sig/file"<br />
====Random signature====<br />
You can use ''fortune'' (package {{Pkg|fortune-mod}}) to add a random signature to Mutt.<br />
<br />
Create a fortune file and then add the following line to your .muttrc:<br />
{{bc|1=set signature="fortune pathtofortunefile&#124;"}}<br />
Note the pipe at the end. It tells Mutt that the specified string is not a file, but a command.<br />
<br />
===Viewing URLs & opening your favorite web browser===<br />
Your should start by creating a .mutt directory in $HOME if not done yet. There, create a file named macros. Insert the following:<br />
macro pager \cb <pipe-entry>'urlview'<enter> 'Follow links with urlview'<br />
<br />
Then install {{AUR|urlview}} from the [[AUR]].<br />
<br />
Create a .urlview in $HOME and insert the following:<br />
REGEXP (((http|https|ftp|gopher)|mailto)[.:][^ >"\t]*|www\.[-a-z0-9.]+)[^ .,;\t>">\):]<br />
COMMAND <your-browser> %s <br />
<br />
When you read an email on the pager, hitting ctrl+b will list all the urls from the email. Navigate up or down with arrow keys and hit enter on the desired url. Your browser will start and go to the selected site.<br />
<br />
Some browser will require additional arguments to work properly. For example, [[Luakit]] will close on Mutt exit. You need to fork it to background, using the {{ic|-n}} parameter:<br />
COMMAND luakit -n %s 2>/dev/null<br />
The {{ic|2>/dev/null}} is to make it quiet, i.e. to prevent useless message printing where you do not want them to.<br />
<br />
{{Note|urlview has a few deficiencies (e.g. the inability to handle certain email encodings) and is fairly feature-bare (e.g. it does not provide context for links it finds). There are a couple alternatives that do better. One, which can handle all email encodings and provides link context, is [http://www.memoryhole.net/~kyle/extract_url/ extract_url.pl]. Another, which can also provide link context but cannot handle all email encodings, is {{AUR|urlscan-git}}. Both are drop-in replacements for urlview, though extract_url has features which benefit from additional configuration changes.}}<br />
<br />
===Viewing HTML===<br />
It is possible to pass the html body to an external HTML program and then dump it, keeping email viewing uniform and unobtrusive. Three programs are described here: {{Pkg|lynx}}, {{Pkg|w3m}} and {{Pkg|elinks}} (make sure the selected package is [[pacman|installed]]).<br />
<br />
If {{ic|~/.mutt/mailcap}} does not exist you will need to create it and save the following to it.<br />
text/html; lynx -assume_charset=%{charset} -display_charset=utf-8 -dump %s; nametemplate=%s.html; copiousoutput<br />
or, in case of w3m,<br />
text/html; w3m -I %{charset} -T text/html; copiousoutput;<br />
or, in case of elinks,<br />
text/html; elinks -dump ; copiousoutput;<br />
<br />
Edit muttrc and add the following,<br />
set mailcap_path = ~/.mutt/mailcap<br />
<br />
To automatically open HTML messages in lynx, add this additional line to the muttrc:<br />
auto_view text/html<br />
<br />
The beauty of this is, instead of seeing an html body as source or being opened<br />
by a separate program, in this case lynx, you see the formatted content directly,<br />
and any url links within the email can be displayed with {{ic|Ctrl+b}}.<br />
<br />
If you receive many emails with multiple or alternate encodings Mutt may default to treating every email as html. To avoid this, add the following variable to your ~/.muttrc to have Mutt default to text when available and use w3m/lynx only when no text version is availble in the email:<br />
alternative_order text/plain text/html<br />
<br />
Some HTML mails may not display correctly in a text-based web browser. As a fallback solution, you can bind a key to open a graphical browser in such cases.<br />
The following macro will open the HTML mail selected from the attachment view in the web browser defined in the environment. (Feel free to adapt the {{ic|~/.cache/mutt/}} folder).<br />
macro attach 'V' "<pipe-entry>cat >~/.cache/mutt/mail.html && $BROWSER ~/.cache/mutt/mail.html && rm ~/.cache/mutt/mail.html<enter>"<br />
<br />
===Mutt and Vim===<br />
*To limit the width of text to 72 characters, edit your .[[vim]]rc file and add:<br />
au BufRead /tmp/mutt-* set tw=72<br />
<br />
*Another choice is to use Vim's mail filetype plugin to enable other mail-centric options besides 72 character width. Edit {{ic|~/.vim/filetype.vim}}, creating it if unpresent, and add:<br />
{{bc| <br />
augroup filetypedetect<br />
" Mail<br />
autocmd BufRead,BufNewFile *mutt-* setfiletype mail<br />
augroup END<br />
}}<br />
<br />
*To set a different tmp directory, e.g. ~/.tmp, add a line to your muttrc as follows:<br />
set tmpdir="~/.tmp"<br />
<br />
*To reformat a modified text see the Vim context help<br />
:h 10.7<br />
<br />
===Mutt and GNU nano===<br />
[[nano]] is another nice console editor to use with Mutt. <br />
<br />
To limit the width of text to 72 characters, edit your .nanorc file and add:<br />
set fill 72<br />
<br />
Also, in muttrc file, you can specify the line to start editing so that you will skip the mail header:<br />
set editor="nano +7"<br />
<br />
===Mutt and Emacs===<br />
Emacs has a ''mail'' and a ''message'' major mode.<br />
To switch to mail-mode automatically when Emacs is called from Mutt, you can add the following to your {{ic|.emacs}}:<br />
{{hc|.emacs|<nowiki><br />
;; Mutt support.<br />
(setq auto-mode-alist (append '(("/tmp/mutt.*" . mail-mode)) auto-mode-alist))<br />
</nowiki>}}<br />
<br />
If you usually run Emacs daemon, you may want Mutt to connect to it. Add this to your {{ic|.muttrc}}:<br />
{{hc|.muttrc|<nowiki><br />
set editor="emacsclient -a \"\" -t"</nowiki><br />
}}<br />
<br />
===Colors===<br />
Append sample color definitions to your .muttrc file:<br />
$ cat /usr/share/doc/mutt/samples/colors.linux >> ~/.muttrc<br />
Then adjust to your liking.<br />
The actual color each of these settings will produce depends on the colors set in your [[Xresources|~/.Xresources]] file.<br />
<br />
Alternatively, you can source any file you want containing colors (and thus act as a theme file):<br />
{{bc|<br />
source ~/.mutt/colors.zenburn<br />
}}<br />
<br />
A nice theme example:<br />
{{bc|<nowiki><br />
## Theme kindly inspired from <br />
## http://nongeekshandbook.blogspot.ie/2009/03/mutt-color-configuration.html <br />
<br />
## Colours for items in the index <br />
color index brightcyan black ~N<br />
color index brightred black ~O<br />
color index brightyellow black ~F<br />
color index black green ~T<br />
color index brightred black ~D<br />
mono index bold ~N<br />
mono index bold ~F<br />
mono index bold ~T<br />
mono index bold ~D<br />
<br />
## Highlights inside the body of a message. <br />
<br />
## URLs <br />
color body brightgreen black "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"<br />
color body brightgreen black "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"<br />
mono body bold "(http|ftp|news|telnet|finger)://[^ \"\t\r\n]*"<br />
mono body bold "mailto:[-a-z_0-9.]+@[-a-z_0-9.]+"<br />
<br />
## Email addresses. <br />
color body brightgreen black "[-a-z_0-9.%$]+@[-a-z_0-9.]+\\.[-a-z][-a-z]+"<br />
<br />
## Header <br />
color header green black "^from:"<br />
color header green black "^to:"<br />
color header green black "^cc:"<br />
color header green black "^date:"<br />
color header yellow black "^newsgroups:"<br />
color header yellow black "^reply-to:"<br />
color header brightcyan black "^subject:"<br />
color header red black "^x-spam-rule:"<br />
color header green black "^x-mailer:"<br />
color header yellow black "^message-id:"<br />
color header yellow black "^Organization:"<br />
color header yellow black "^Organisation:"<br />
color header yellow black "^User-Agent:"<br />
color header yellow black "^message-id: .*pine"<br />
color header yellow black "^X-Fnord:"<br />
color header yellow black "^X-WebTV-Stationery:"<br />
<br />
color header red black "^x-spam-rule:"<br />
color header green black "^x-mailer:"<br />
color header yellow black "^message-id:"<br />
color header yellow black "^Organization:"<br />
color header yellow black "^Organisation:"<br />
color header yellow black "^User-Agent:"<br />
color header yellow black "^message-id: .*pine"<br />
color header yellow black "^X-Fnord:"<br />
color header yellow black "^X-WebTV-Stationery:"<br />
color header yellow black "^X-Message-Flag:"<br />
color header yellow black "^X-Spam-Status:"<br />
color header yellow black "^X-SpamProbe:"<br />
color header red black "^X-SpamProbe: SPAM"<br />
<br />
## Coloring quoted text - coloring the first 7 levels: <br />
color quoted cyan black<br />
color quoted1 yellow black<br />
color quoted2 red black<br />
color quoted3 green black<br />
color quoted4 cyan black<br />
color quoted5 yellow black<br />
color quoted6 red black<br />
color quoted7 green black<br />
<br />
## Default color definitions <br />
#color hdrdefault white green <br />
color signature brightmagenta black<br />
color indicator black cyan<br />
color attachment black green<br />
color error red black<br />
color message white black<br />
color search brightwhite magenta<br />
color status brightyellow blue<br />
color tree brightblue black<br />
color normal white black<br />
color tilde green black<br />
color bold brightyellow black<br />
#color underline magenta black <br />
color markers brightcyan black<br />
<br />
## Colour definitions when on a mono screen <br />
mono bold bold<br />
mono underline underline<br />
mono indicator reverse</nowiki><br />
}}<br />
<br />
===Index Format===<br />
<br />
Here follows a quick example to put in your {{ic|.muttrc}} to customize the Index Format, i.e. the columns displayed in the folder view.<br />
{{bc|<nowiki><br />
set date_format="%y-%m-%d %T"<br />
set index_format="%2C | %Z [%d] %-30.30F (%-4.4c) %s"</nowiki><br />
}}<br />
See the [http://www.mutt.org/doc/manual/manual-6.html Mutt Reference], {{ic|man 3 strftime}} and {{ic|man 3 printf}} for more details.<br />
<br />
====Display recipient instead of sender in "Sent" folder view====<br />
<br />
By default Mutt will display the sender in the index view. It is fine for most folders, but rather useless for the one were you store a copy of your sent e-mails since it will always display your name.<br />
<br />
The "columns" of the index can be configured through the {{ic|index_format}} variable. Its syntax is documented in the {{ic|muttrc}} man page. The values of our concern are {{ic|%t}} (recipient) and {{ic|%F}} (sender).<br />
<br />
To change the columns according to the current folder, we need to use a hook:<br />
{{hc|muttrc|<nowiki><br />
folder-hook *[sS]ent* 'set index_format="%2C | %Z [%d] %-30.30t (%-4.4c) %s"'<br />
folder-hook ! *[sS]ent* 'set index_format="%2C | %Z [%d] %-30.30F (%-4.4c) %s"'<br />
</nowiki>}}<br />
<br />
The exclamation mark means ''everything that does not match the following regex''. Of course you can change the index_format following you taste, and the regular expression if the folder does not have ''Sent'' not ''sent'' in its name.<br />
<br />
====Variable column width====<br />
<br />
If you resize the window, the subject might get truncated while there is still unused space left for some fields, like for the sender.<br />
You can get the maximum number of columns supported by your terminal (i.e. the width) using a shell call to {{ic|tput cols}}. With this value, you can set a percentage of the width to fields like Sender and Subject.<br />
<br />
Example using the above folder-hook and a sidebar width of 24:<br />
{{hc|muttrc|<nowiki><br />
## From field gets 30% of remaining space, Subject gets 70%.<br />
## Remaining space is the total width minus the other fields (35), minus the sidebar (24)<br />
set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`<br />
set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`<br />
<br />
folder-hook .*[sS]ent.* 'set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}t (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
folder-hook ! .*[sS]ent.* 'set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}F (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
</nowiki><br />
}}<br />
<br />
Unfortunately, the above example suffers from one caveat: the {{ic|my_col_*}} variables get computed one time only, on first start. So if you want it to refresh automatically, we need to set the variable in a hook. Sadly there is no hook for window resizing, but you can still use the {{ic|folder-hook}} so that a simple folder switch suffices to recompute the view.<br />
{{hc|muttrc|<nowiki><br />
folder-hook .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`; set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}t (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
folder-hook ! .*[sS]ent.* 'set my_col_from = `echo $((30 * ($(tput cols)-35-24) / 100))`; set my_col_subject = `echo $((70 * ($(tput cols)-35-24) / 100))`; set index_format="%2C | %Z [%d] %-$my_col_from.${my_col_from}F (%-4.4c) %-$my_col_subject.${my_col_subject}s"'<br />
</nowiki><br />
}}<br />
<br />
===Contact management===<br />
<br />
====Address aliases====<br />
''Aliases'' is the way Mutt manages contacts.<br />
An alias is '''nickname [longname] <address>'''.<br />
* The '''nickname''' is what you will type in Mutt to get your contact address. One word only, and should be easy to remember.<br />
* The '''longname''' is optional. It may be several words.<br />
* An '''<address>''' must be in a valid form (i.e. with an {{ic|@}}).<br />
<br />
It is quite simple indeed. Add this to {{ic|.muttrc}}:<br />
{{bc|1=<br />
set alias_file = "~/.mutt/aliases"<br />
set sort_alias = alias<br />
set reverse_alias = yes<br />
source $alias_file<br />
}}<br />
<br />
Explanation:<br />
* {{ic|alias_file}} is the file where the information is getting stored when you add an alias from within Mutt.<br />
* {{ic|sort_alias}} specifies which field to use to sort the alias list when displayed in Mutt. Possible values: alias, address.<br />
* {{ic|reverse_alias}} sorts in reverse order if set to yes.<br />
* {{ic|source $alias_file}} tells Mutt to read aliases on startup. Needed for auto-completion.<br />
<br />
Now all you have to do when prompted {{ic|To:}} is writing the alias instead of the full address. The beauty of it is that you can auto-complete the alias using {{ic|Tab}}.<br />
Autocompleting a wrong or an empty string will display the full list. You can select the alias as usual, or by typing its index number.<br />
<br />
There are two ways to create aliases:<br />
* From Mutt, press {{ic|a}} when an e-mail of the targetted person if selected.<br />
* Edit the alias_file manually. The syntax is really simple:<br />
{{bc|<br />
alias nickname Long Name <my-friend@domain.tld><br />
}}<br />
<br />
====Abook====<br />
<br />
{{pkg|abook}} is a stand-alone program dedicated to contact management. It uses a very simple text-based interface and contacts are stored in a plain text, human-readable database. Besides the desired contact properties are extensible (birthday, address, fax, and so on).<br />
<br />
Abook is specifically designed to be interfaced with Mutt, so that it can serve as a full, more featured replacement of Mutt internal aliases. If you want to use Abook instead of aliases, remove the aliases configuration in {{ic|.muttrc}} and add this:<br />
<br />
{{hc|muttrc|<nowiki><br />
## Abook<br />
set query_command= "abook --mutt-query '%s'"<br />
macro index,pager a "<pipe-message>abook --add-email-quiet<return>" "Add this sender to Abook"<br />
bind editor <Tab> complete-query<br />
</nowiki><br />
}}<br />
<br />
See the man pages {{ic|abook}} and {{ic|abookrc}} for more details and a full configuration sample.<br />
<br />
===Request IMAP mail retrieval manually===<br />
If you do not want to wait for the next automatic IMAP fetching (or if you did not enable it), you might want to fetch mails manually.<br />
There is a mutt command {{ic|imap-fetch-mail}} for that.<br />
Alternatively, you could bind it to a key:<br />
bind index "^" imap-fetch-mail<br />
<br />
===Avoiding slow index on large (IMAP) folders due to coloring===<br />
<br />
Index highlighting by regex is nice, but can lead to slow folder viewing if your regex checks the body of the message.<br />
<br />
Use folder-hook for only highlighting in for example the inbox (if you manage to empty your mailbox effiently):<br />
<br />
folder-hook . 'uncolor index "~b \"Hi Joe\" ~R !~T !~F !~p !~P"'<br />
folder-hook ""!"" 'color index brightyellow black "~b \"Hi Joe\" ~N !~T !~F !~p !~P"'<br />
<br />
===Speed up folders switch===<br />
Add this to your {{ic|.muttrc}}:<br />
{{bc|1=<br />
set sleep_time = 0<br />
}}<br />
<br />
===Use Mutt to send mail from command line===<br />
Man pages will show all available commands and how to use them, but here are a couple of examples. You could use Mutt to send alerts, logs or some other system information, triggered by login through .bash_profile, or as a regular cron job.<br />
<br />
Send a message:<br />
mutt -s "Subject" somejoeorjane@someserver.com < /var/log/somelog<br />
<br />
Send a message with attachment:<br />
mutt -s "Subject" somejoeorjane@someserver.com -a somefile < /tmp/sometext.txt<br />
<br />
===Composing HTML e-mails===<br />
<br />
Since Mutt has nothing of a WYSIWIG client, HTML is quite straightforward, and you can do much more than with all WYSIWIG mail clients around since you edit the source code directly.<br />
Simply write your mail using HTML syntax. For example:<br />
{{bc|<nowiki><br />
This is normal text<br><br />
<b>This is bold text</b></nowiki><br />
}}<br />
Now before sending the mail, use the {{ic|edit-type}} command (default shortcut {{ic|Ctrl+t}}), and replace {{ic|text/plain}} by {{ic|text/html}}.<br />
<br />
{{Note|HTML e-mails are regarded by many people as useless, cumbersome, and subject to reading issues. Mutt can read HTML mails with a text browser like w3m or lynx, but it has clearly no advantage over a plain-text e-mail. You should avoid writing HTML e-mails when possible.}}<br />
<br />
===How to display another email while composing===<br />
A common complaint with Mutt is that when composing a new mail (or reply), you cannot open another mail (i.e. for checking with another correspondent) without closing the current mail (postponing). The following describes a solution:<br />
<br />
First, fire up Mutt as usual. Then, launch another terminal window. Now start a new Mutt with <br />
mutt -R<br />
This starts Mutt in read-only mode, and you can browse other emails at your convenience. It is strongly recommended to always launch a second Mutt in read-only mode, as conflicts will easily arise otherwise.<br />
<br />
{{Note|When changing folders (with {{ic|c}} or {{ic|y}}) the read-only mode is not preserved. Instead {{ic|Esc c}} has to be used.}}<br />
<br />
{{Tip|This solution calls for a bit of typing, so it is suitable to bind the following command to a keyboard shortcut (see [[Extra Keyboard Keys]] for details):<br />
$TERMINAL -e mutt -R <br />
where {{ic|$TERMINAL}} is your terminal.}}<br />
<br />
===Archive treated e-mails===<br />
When you read an e-mail, you have four choices: Answer it, Flag it, Archive it or Delete it. If you have this in mind, you can keep your inbox slim and fit with this macro (set up for Gmail):<br />
<br />
macro index \' "<tag-pattern>~R !~D !~F<enter>\<br />
<tag-prefix><save-message>+[Gmail]/All <enter>" \<br />
"Archive"<br />
<br />
===Mutt-Sidebar===<br />
<br />
The vanilla Mutt does not feature a sidebar unlike most MUAs. If you miss it, you can install {{AUR|mutt-sidebar}} from the AUR which features a patch for a list of folders on the left side of the Mutt window.<br />
<br />
For a while there has been several different patches for the sidebar. Since the late 2000's, it seems like the main patch is maintained at [http://www.lunar-linux.org/mutt-sidebar/ Lunar Linux]. See the documentation there. Note that the patch also updates the {{ic|muttrc}} man page, so have a look at the {{ic|sidebar_*}} sections.<br />
<br />
You can choose to display the sidebar on startup, or to prompt it manually with a key:<br />
{{bc|<nowiki><br />
set sidebar_visible = yes<br />
macro index b '<enter-command>toggle sidebar_visible<enter><refresh>'<br />
macro pager b '<enter-command>toggle sidebar_visible<enter><redraw-screen>'<br />
</nowiki>}}<br />
<br />
You also probabaly need some shortcuts to navigate in the bar:<br />
{{bc|<nowiki><br />
# Ctrl-n, Ctrl-p to select next, previous folder.<br />
# Ctrl-o to open selected folder.<br />
bind index,pager \CP sidebar-prev<br />
bind index,pager \CN sidebar-next<br />
bind index,pager \CO sidebar-open<br />
</nowiki>}}<br />
<br />
{{Note|You ''must'' set the {{ic|mailboxes}} variables or the {{ic|imap_check_subscribed}} to tell the sidebar which folder should be displayed. See the [[#mailboxes|mailboxes]] section.}}<br />
<br />
If you use the {{ic|imap_check_subscribed}} option to list all your folders, they will appear in an uncontrollable order in the sidebar. Fix it with<br />
set sidebar_sort = yes<br />
Note that with the {{ic|mailboxes}} option, folders appear in the order they were set to {{ic|mailboxes}} if you do not use the {{ic|sidebar_sort}} option.<br />
<br />
If you have trouble with truncated names, set the option<br />
set sidebar_shortpath = yes<br />
<br />
Finally, you may want to add a separator between different mailboxes. The sidebar patch does not currently provide any kind of separator option. A simple (and dirty) workaround is to add a fake folder to the list of folders:<br />
mailboxes "+-- My mailbox -----------"<br />
The dashes are not required, they are here just for fancy output.<br />
It will also work if you used the {{ic|imap_check_subscribed}} option.<br />
If you chose to sort the folders, the separator will not appear in the correct place, so an even more dirty workaround is to add an 'A' in front of the name. Note that punctuation is ignored during sorting.<br />
mailboxes "+A-- My mailbox -----------"<br />
<br />
===Migrating mails from one computer to another===<br />
In case you are transfering your mails to a new machine (copy&paste), you probably need to delete the header cache (a file or folder like {{ic|~/.cache/mutt}} if you followed the above configuration) to make Mutt able to read your migrated E-Mails. Otherwise Mutt may freeze.<br />
<br />
Note that if you had a folder created for you header cache, all mailboxes will have their own cache file, so you can delete caches individually without having to remove everything.<br />
<br />
=== Filtering the message view ===<br />
<br />
You can restrict the view to e-mails matching a pattern and specific properties with the {{ic|limit}} command (default shortcut: {{ic|l}}).<br />
<br />
To view all e-mails containing "foo" in the header, simply write "foo" and you are done. To remove the filter, use the "all" keyword.<br />
<br />
To view all flagged messages, use<br />
~F<br />
To view all unread messages, use<br />
~U<br />
<br />
All possible patterns are listed in the [http://www.mutt.org/doc/manual/manual-4.html#ss4.2 official manual].<br />
<br />
=== Display the index above the pager view ===<br />
<br />
Set the following variable in your {{ic|muttrc}}:<br />
set pager_index_lines=10<br />
<br />
==Troubleshooting==<br />
<br />
===Backspace does not work in Mutt===<br />
This is a common problem with some xterm-like terminals.<br />
Two solutions:<br />
* Either rebind the key in {{ic|.muttrc}}<br />
bind index,pager ^? previous-line<br />
Note that {{ic|^?}} is one single character representing backspace in [[wikipedia:Caret_notation|caret notation]]. To type in Emacs, use {{ic|Ctrl+q Backspace}}, in Vim {{ic|Ctrl+v Backspace}}.<br />
<br />
* Or fix your terminal:<br />
$ infocmp > termbs.src<br />
Edit {{ic|termbs.src}} and change {{ic|1= kbs=^H}} to {{ic|1= kbs=\177}}, then:<br />
$ tic -x termbs.src<br />
<br />
===Android's default MUA receives empty e-mail with attachment "Unknown.txt"===<br />
<br />
This is because Mutt adds 'Content-Disposition' line to every e-mail header. This line is actually correct, the issue comes from Android 2 MUA misinterpreting it. This bug seems to be fixed in the Android 4 MUA.<br />
There is a patched version for Android available in the AUR. Installing {{AUR|mutt-android-patch}} will fix the issue.<br />
<br />
===The ''change-folder'' function always prompt for the same mailbox ===<br />
<br />
This is not a bug, this is actually an intended behaviour. See the [[#Multiple accounts|multiple accounts section]] for a workaround.<br />
<br />
===I cannot change folder when using Mutt read-only (Mutt -R)===<br />
<br />
This is certainly because you are using macros like this one:<br />
macro index,pager <f2> '<sync-mailbox><enter-command>source ~/.mutt/personal<enter><change-folder>!<enter>'<br />
This macro tells Mutt to sync (which is a write operation) before switching.<br />
Either use the [[#Mutt-Sidebar|sidebar]] or set another macro:<br />
macro index,pager <f3> '<enter-command>source ~/.mutt/personal<enter><change-folder>!<enter>'<br />
<br />
===Error sending message, child exited 127 (Exec error.).===<br />
This is an SMTP error. It means that mutt does not know how to send the message.<br />
You can either try installing sendmail and see if that solves your issue, or you can set the smtp_url variable. If you use gmail, you can add the following to your muttrc to tell mutt to use gmails smtp server.<br />
<br />
set smtp_url=smtps://$imap_user:$imap_pass@smtp.gmail.com<br />
<br />
Take note of the smtps protocol, it is important.<br />
This should solve the problem.<br />
<br />
== Documentation ==<br />
<br />
Newcomers may find it quite hard to find help for Mutt. Actually most of the topics are covered in the official documentation. We urge you to read it.<br />
<br />
* [http://www.mutt.org/doc/manual/ The official manual]. The stock {{pkg|mutt}} package for Arch Linux also installs the HTML and plain text manual at {{ic|/usr/share/doc/mutt/}}.<br />
* The {{ic|mutt}} and {{ic|muttrc}} man pages.<br />
<br />
== See also ==<br />
* [http://www.mutt.org/ The official Mutt website]<br />
* [http://wiki.mutt.org/ The Mutt wiki]<br />
* [http://pbrisbin.com/posts/two_accounts_in_mutt/ Brisbin's great guide on how to setup different IMAP accounts with Mutt, offlineimap, msmtp]<br />
* [http://srobb.net/mutt.html A Quick Guide to Mutt]<br />
* [http://stevelosh.com/blog/2012/10/the-homely-mutt/ Steve Losh on Mutt, offlineimap, msmtp, notmuch (focused on Gmail)]<br />
* [http://www.muttrcbuilder.org/ muttrc builder]</div>Paris3200https://wiki.archlinux.org/index.php?title=Music_Player_Daemon&diff=240936Music Player Daemon2012-12-20T01:49:02Z<p>Paris3200: /* Console */ Updated ncmpcpp to link to the ncmpcpp wiki page.</p>
<hr />
<div>[[Category:Player]]<br />
[[de:Music Player Daemon]]<br />
[[es:Music Player Daemon]]<br />
[[fr:MPD]]<br />
[[it:Music Player Daemon]]<br />
[[nl:Music Player Daemon]]<br />
[[pl:Music Player Daemon]]<br />
[[ru:Music Player Daemon]]<br />
[[sr:Music Player Daemon]]<br />
[[tr:Music_Player_Daemon]]<br />
[[zh-CN:Music Player Daemon]]<br />
{{Article summary start}}<br />
{{Article summary text|Installation, configuration and basic troubleshooting of MPD.}}<br />
{{Article summary heading|Required software}}<br />
{{Article summary link|Music Player Daemon|http://mpd.wikia.com}}<br />
{{Article summary heading|Related Articles}}<br />
{{Article summary wiki|MPD/Tips and Tricks}}<br />
{{Article summary wiki|MPD/Troubleshooting}}<br />
{{Article summary heading|Other sources}}<br />
{{Article summary text|[[Wikipedia:MPD|Wikipedia article]]}}<br />
{{Article summary end}}<br />
<br />
'''MPD''' ('''m'''usic '''p'''layer '''d'''aemon) is an audio player that has a server-client architecture. It plays audio files, organizes playlists and maintains a music database all while using very few resources. In order to interface with it, a separate [[#Clients|client]] is needed.<br />
<br />
== Installation ==<br />
=== Stable version ===<br />
The latest stable version of {{Pkg|mpd}} is available in the [[official repositories]].<br />
<br />
You may also want to install [https://github.com/GutenYe/systemd-units/tree/master/mpd mpd-systemd].<br />
<br />
=== Git version ===<br />
Should users wish to run an experimental version, the [[AUR]] offers several from which to choose. For example, {{AUR|mpd-git}}.<br />
<br />
== Setup ==<br />
MPD is able to run globally (settings apply to all users), locally (per user settings), and in multiple instances.<br />
The way of setting up mpd depends on the way it is intended to be used.<br />
A local configuration may prove more useful on a desktop system than on a system that is used by several people simultaneously.<br />
<br />
For a comfortable use, it is sensible to provide MPD access to the following files and directories:<br />
* mpd.db - The music database<br />
* mpd.pid - The file where mpd stores its process ID<br />
* mpd.log - mpd logs here<br />
* mpdstate - mpd's current state is noted here<br />
* playlists - the folder where playlists are saved into<br />
<br />
In order for MPD to be able to play back audio, [[ALSA]], [[PulseAudio]] or [[OSS]] needs to be setup and working.<br />
<br />
=== Local Configuration (per user) ===<br />
MPD does not need to be run globally as a daemon and can rather work per user. The usual method to configure MPD globally is because the listed files and folders in the default configuration file point to directories owned by root (the {{ic|/var}} directory).<br />
<br />
A less used (but perhaps more sensible) method is to make MPD work with files and directories owned by a normal user. Running MPD as a normal user has the benefits of:<br />
<br />
* A single directory {{ic|~/.mpd}} (or any other directory under {{ic|/home/username}}) that will contain all the MPD configuration files.<br />
* Easier to avoid unforeseen read/write permission errors.<br />
<br />
{{Note|This approach will not work with multiple users to having access to MPD at the same time.}}<br />
<br />
Begin the setup by creating a directory for the required files and the playlists:<br />
<br />
{{bc|mkdir -p ~/.mpd/playlists}}<br />
<br />
Copy the contents of the default MPD configuration file in {{ic|/usr/share/mpd/mpd.conf.example}} to the target user's home directory:<br />
<br />
{{bc|cp /usr/share/doc/mpd/mpdconf.example ~/.mpdconf}}<br />
<br />
Create all of the requisite files:<br />
<br />
{{bc|<nowiki>touch ~/.mpd/{database,log,pid,state}</nowiki>}}<br />
<br />
Edit {{ic|~/.mpdconf}} to specify these files:<br />
<br />
{{hc|~/.mpdconf|<br />
music_directory "/home/USER/music" # Keep commented if your XDG directory already points to it<br />
playlist_directory "/home/USER/.mpd/playlists"<br />
db_file "/home/USER/.mpd/db"<br />
log_file "/home/USER/.mpd/log"<br />
pid_file "/home/USER/.mpd/pid"<br />
state_file "/home/USER/.mpd/state"<br />
}}<br />
<br />
or you can use<br />
{{bc|sed "s/var\/lib\/mpd\/music/home\/$USER\/music/;<br />
s/var\/lib\/mpd/home\/$USER\/.mpd/;<br />
s/var\/run\/mpd/home\/$USER\/.mpd/;<br />
s/var\/log\/mpd/home\/$USER\/.mpd/" /etc/mpd.conf > ~/.mpd/mpd.conf}}<br />
<br />
MPD can now be started by typing {{ic|mpd}} on the command line.<br />
<br />
To start MPD with the X server, add<br />
{{bc|mpd ~/.mpdconf}}<br />
to either [[xprofile]] or [[xinitrc]]<br />
<br />
==== Start MPD per user with systemd ====<br />
<br />
As recommended above, it is best to use MPD as a service per user. In this case, we will use {{ic|~/.mpd/mpd.conf}} and not start mpd.service as a daemon for the whole system and all users.<br />
We will NOT use the {{ic|/usr/lib/systemd/system/mpd.service}} which is intended to start the mpd.service as root and for all users.<br />
If you already enabled it, just disable it first:<br />
{{bc| # systemctl disable mpd.service}}<br />
<br />
If you used to start mpd inside your {{ic|~/.xinitrc}}, comment or delete the line<br />
{{bc|mpd ~/.mpdconf}}<br />
<br />
Then, edit a new file ~/.config/systemd/user/mpd.service <br />
{{hc|~/.config/systemd/user/mpd.service|<br />
[Unit]<br />
Description &#61; Music Player Daemon<br />
<br />
[Service]<br />
ExecStart &#61; /usr/bin/mpd --no-daemon<br />
Restart &#61; always<br />
<br />
[Install]<br />
WantedBy &#61; default.target<br />
}}<br />
<br />
Then, add this line to [[xinitrc|.xinitrc]] before any exec <session-command><br />
{{hc|~/.xinitrc|<br />
#run systemd as user instance<br />
systemd --user &<br />
}}<br />
<br />
Log out, log in your xsession.<br />
Let's first check mpd is not running. If yes, just kill it. If not, continue to the next step.<br />
{{bc|$ ps -ef &#124; grep mpd}}<br />
<br />
Now, enable and start mpd.service as per user <br />
$ systemctl --user enable mpd<br />
$ systemctl --user start mpd<br />
<br />
Check the mpd status and see if mpd.service is correctly enabled and started<br />
{{bc|$ systemctl --user status mpd}}<br />
<br />
Alternately, if you're already running systemd and don't want to run it again as a user instance, you can copy the following unit file to {{ic|/etc/systemd/system/multi-user.target.wants}}, changing USERNAME to the desired user to run as:<br />
<br />
{{hc|/etc/systemd/system/multi-user.target.wants/mpd-user.service|<br />
[Unit]<br />
Description&#61;Music Player Daemon<br />
After&#61;sound.target<br />
<br />
[Service]<br />
User&#61;USERNAME<br />
ExecStart&#61;/usr/bin/mpd --no-daemon<br />
Restart&#61;always<br />
<br />
[Install]<br />
WantedBy&#61;default.target<br />
}}<br />
<br />
Don't forget to have systemd rescan unit files: {{ic|# systemctl daemon-reload}} and start the service: {{ic|# systemctl start mpd-user.service}}.<br />
<br />
==== Scripted Configuration ====<br />
Rasi has written a script that will create the proper directory structure, configuration files and prompt for the location of the user's Music directory; it can be downloaded [http://karif.server-speed.net/~carnager/mpdsetup.tar here].<br />
<br />
=== Global Configuration ===<br />
{{Note|For user-specific permissions, change the "user" line above to reflect one of the system users.}}<br />
{{Warning|Users of PulseAudio with a local mpd have to implement a [[Music Player Daemon/Tips and Tricks#Local (with separate mpd user)|workaround]] in order to run mpd as its own user!}}<br />
<br />
MPD comes with an example configuration file, available at {{ic|/usr/share/doc/mpd/mpdconf.example}}. This file holds an abundance of information on MPD configuration, and holds default mixer values.<br />
<br />
Normally,{{ic|/etc/mpd.conf}} is created when installing mpd. If not, copy the included example file to {{ic|/etc/mpd.conf}}.<br />
# cp /usr/share/doc/mpd/mpdconf.example /etc/mpd.conf<br />
<br />
==== Editing mpd.conf ====<br />
The default Arch install keeps the setup in {{ic|/var/lib/mpd}} and uses "mpd" as default user.<br />
<br />
Edit {{ic|/etc/mpd.conf}} to reflect as such:<br />
{{hc|/etc/mpd.conf|<br />
music_directory "/home/user/music"<br />
playlist_directory "/var/lib/mpd/playlists"<br />
db_file "/var/lib/mpd/mpd.db"<br />
log_file "/var/log/mpd/mpd.log"<br />
pid_file "/run/mpd/mpd.pid"<br />
state_file "/var/lib/mpd/mpdstate"<br />
user "mpd"<br />
# bind_to_address "127.0.0.1"<br />
# port "6600"<br />
}}<br />
Now change permissions for mpd to write to {{ic|/var/log/mpd/mpd.log}}, otherwise mpd will return an error when it is started. The best way is to make the {{ic|/var/log/mpd/mpd.log}} belong to the mpd [[Users and Groups#Group management|user]].<br />
# chown -R mpd /var/log/mpd <br />
Run this to create the /run/mpd dir:<br />
# systemd-tmpfiles --create mpd.conf<br />
To change the volume for mpd independent from other programs, uncomment or add this switch in mpd.conf:<br />
<br />
{{hc|/etc/mpd.conf|<br />
mixer_type "software"<br />
}}<br />
<br />
Users of [[PulseAudio]] will need to make the following modification:<br />
{{hc|/etc/mpd.conf|2=<br />
audio_output {<br />
type "pulse"<br />
name "pulse audio"<br />
}<br />
}}<br />
<br />
Users of [[ALSA]] will want to have the following device definition, which allows software volume control in the MPD client to control the volume separately from other applications.<br />
{{hc|/etc/mpd.conf|2=<br />
audio_output {<br />
type "alsa"<br />
name "My Sound Card"<br />
mixer_type "software" # optional<br />
}<br />
}}<br />
<br />
Changing the group that MPD runs as may result in errors like "output: Failed to open "My ALSA Device"" "[alsa]: Failed to open ALSA device "default": No such file or directory" "player_thread: problems opening audio device while playing "Song Name.mp3""<br />
<br />
This is because by default MPD runs as member of '''audio''' group and the sound devices under {{Ic|/dev/snd/}} are owned by this group, so add user {{Ic|mpd}} to group {{Ic|audio}}.<br />
# gpasswd -a mpd audio<br />
<br />
===== Music directory =====<br />
MPD needs to have {{ic|+x}} permissions on ''all'' parent directories to the music collection (ie. if it's located outside of "mpd" home directory {{ic|/var/lib/mpd}}). By default useradd sets permissions on home directories to {{ic|1700 drwx------}}. Thus users will most likely need to remount the music directory under a directory that mpd has access to -- this only applies if running as the 'mpd' user.<br />
<br />
# mkdir /var/lib/mpd/music<br />
# echo "/home/$USER/music /var/lib/mpd/music none bind" >> /etc/fstab<br />
# mount -a<br />
# systemctl restart mpd.service<br />
Also see [https://bbs.archlinux.org/viewtopic.php?id=86449 this forum thread.]<br />
<br />
An additional solution would be to just create a symbolic link into {{ic|/var/lib/mpd/music}}.<br />
# mkdir /var/lib/mpd/music<br />
# ln -s MUSIC_FOLDER /var/lib/mpd/music/<br />
# systemctl restart mpd.service<br />
<br />
If the music collection is contained under multiple directories, create symbolic links under the main music directory in {{ic|/var/lib/mpd}}. Remember to set permissions accordingly on the directories being linked.<br />
<br />
==== Creating the required files ====<br />
Now, having finished configuring MPD, the files and directories for MPD to write in need to be created:<br />
<br />
Create the directories and files specified in {{ic|/etc/mpd.conf}}:<br />
# mkdir -p /var/lib/mpd/playlists <br />
# touch /var/lib/mpd/{mpd.db,mpdstate} <br />
<br />
Usually the init-script should properly create {{ic|/run/mpd/}} when starting. The daemon will use this directory to create {{ic|mpd.pid}} in it. However, when running mpd as a different user, requires an update to the tmpfiles.d: copy {{ic|/usr/lib/tmpfiles.d/mpd.conf}} to {{ic|/etc/tmpfiles.d/mpd.conf}}:<br />
Change:<br />
d /run/mpd 0755 mpd mpd<br />
to:<br />
d /run/mpd 0755 ''username'' ''groupname''<br />
<br />
Change the file's permissions so that the daemon can modify them.<br />
# chown -R mpd /var/lib/mpd<br />
<br />
==== Create database ====<br />
Creating the database is now accomplished via the update feature of the client, for example {{ic|mpc update}}. You'll need to install the mpc package for this. It is in the official repositories<br />
{{Box RED | Note: | Creating the MPD database as root using {{ic|# mpd --create-db}} is deprecated.}}<br />
<br />
==== Timeline of MPD startup ====<br />
To depict when MPD drops its superuser privileges and assumes those of the user set in the configuration, the timeline of a normal MPD startup is listed here:<br />
<br />
# Since MPD is started as root by systemd, it first reads the {{ic|/etc/mpd.conf}} file.<br />
# MPD reads the user variable in the {{ic|/etc/mpd.conf}} file, and changes from root to this user.<br />
# MPD then reads the contents of the {{ic|/etc/mpd.conf}} file and configures itself accordingly.<br />
<br />
Notice that MPD changes the running user from root to the one named in the {{ic|/etc/mpd.conf}} file. <br />
This way, uses of {{ic|~}} in the configuration file point correctly to the home user's directory, and not root's directory. <br />
It may be worthwhile to change all uses of {{ic|~}} to {{ic|/home/username}} to avoid any confusion over this aspect of MPD's behavior.<br />
<br />
=== Multi-mpd setup ===<br />
'''Useful if running an icecast server.'''<br />
<br />
For a second MPD (e.g., with icecast output to share music over the network) using the same music and playlist as the one above, simply copy the above configuration file and make a new file (e.g., {{ic|/home/username/.mpd/config-icecast}}), and only change the log_file, error_file, pid_file, and state_file parameters (e.g., {{ic|mpd-icecast.log}}, {{ic|mpd-icecast.error}}, and so on); using the same directory paths for the music and playlist directories would ensure that this second mpd would use the same music collection as the first one e.g., creating and editing a playlist under the first daemon would affect the second daemon as well. Users do not have to create the same playlists all over again for the second daemon. Call this second daemon the same way from {{ic|~/.xinitrc}} above. (Just be sure to have a different port number, so as to not conflict with the first mpd daemon).<br />
<br />
== Clients ==<br />
A separate client is needed to control mpd. Popular options are:<br />
<br />
=== Console ===<br />
*{{App|mpc|Simple KISS client. All basic functionality available|http://mpd.wikia.com/wiki/Client:Mpc|{{Pkg|mpc}}}}<br />
*{{App|ncmpc|A NCurses client for mpd|http://mpd.wikia.com/wiki/Client:Ncmpc|{{Pkg|ncmpc}}}}<br />
*{{App|[[ncmpcpp]]|An almost exact clone of ncmpc with some new features written in C++ (tag editor, search engine)|http://unkart.ovh.org/ncmpcpp/|{{Pkg|ncmpcpp}}}}<br />
*{{App|pms|Highly configurable and accessible ncurses client|http://pms.sourceforge.net/|{{AUR|pmus}}}}<br />
<br />
=== Graphical ===<br />
*{{App|Ario|A very feature-rich GTK2 GUI client for mpd, inspired by Rhythmbox|http://ario-player.sourceforge.net/|{{Pkg|ario}}}}<br />
*{{App|QmpdClient|A GUI client written with Qt 4.x|http://bitcheese.net/wiki/QMPDClient|{{Pkg|qmpdclient}}}}<br />
*{{App|Sonata|An elegant Python GTK+ client|http://sonata.berlios.de/|{{Pkg|sonata}}}}<br />
*{{App|gmpc|GNOME Client|http://gmpc.wikia.com/wiki/Gnome_Music_Player_Client|{{Pkg|gmpc}}}}<br />
*{{App|Dmpc|Dmenu-based MPC client with a playlist manager and state-saving on playlist changes|http://wintervenom.mine.nu/|{{AUR|dmpc}}}}<br />
<br />
=== Web ===<br />
*{{App|Patchfork|web client for MPD written in PHP and Ajax|http://mpd.wikia.com/wiki/Client:Pitchfork|{{AUR|patchfork-git}}}}.<br />
<br />
See a long list of clients at the [http://mpd.wikia.com/wiki/Clients mpd wiki].<br />
<br />
== External links ==<br />
* [http://mpd.wikia.com/wiki/Clients Sorted List of MPD Clients]<br />
* [http://www.musicpd.org/forum/ MPD forum]</div>Paris3200https://wiki.archlinux.org/index.php?title=Bash&diff=239604Bash2012-12-09T03:25:11Z<p>Paris3200: /* See also */</p>
<hr />
<div>[[Category:Command shells]] <br />
[[de:Bash]]<br />
[[es:Bashrc]]<br />
[[it:Bash]]<br />
[[nl:Bashrc]]<br />
[[zh-CN:Bash]]<br />
{{Article summary start}}<br />
{{Article summary text|Discussing and improving Bash's capabilities.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Readline}}<br />
{{Article summary wiki|Environment Variables}}<br />
{{Article summary wiki|Color Bash Prompt}}<br />
{{Article summary end}}<br />
'''Bash''' (Bourne-again Shell) is a [[Command shell|shell]]/programming language by the [[GNU Project]]. Its name is a homaging reference to its predecessor: the long-deprecated Bourne shell. Bash can be run on most UNIX-like operating systems, including GNU/Linux.<br />
<br />
==Invocation==<br />
Bash behaviour can be altered depending on how it is invoked. Some descriptions of different modes follow.<br />
===Login shell===<br />
If Bash is spawned by {{ic|login}} in a tty, by an [[SSH]] daemon, or similar means, it is considered a login shell. This mode can also be engaged using the {{Ic|-l}} or {{Ic|--login}} command line options.<br />
<br />
===Interactive shell===<br />
Bash is considered an interactive shell if it is started neither with the {{Ic|-c}} option nor any non-option arguments, and whose standard input and error are connected to terminals.<br />
<br />
===POSIX compliance===<br />
Bash can be run with enhanced POSIX compliance by starting Bash with the {{Ic|--posix}} command-line option or executing ‘{{Ic|set -o posix}}’ while Bash is running.<br />
<br />
===Legacy mode===<br />
In Arch {{ic|/bin/sh}} (which used to be the Bourne shell executable) is symlinked to {{ic|/bin/bash}}.<br />
<br />
If Bash is invoked with the name {{Ic|sh}}, it tries to mimic the startup behavior of historical versions of {{Ic|sh}}.<br />
<br />
==Configuration==<br />
{{poor writing}}<br />
===Configuration file overview===<br />
* {{ic|/etc/profile}}<br />
* {{ic|~/.bash_profile}}<br />
* {{ic|~/.bash_login}}<br />
* {{ic|~/.profile}}<br />
* {{ic|/etc/bash.bashrc}} (''Non-standard'': only some distros, Arch included)<br />
* {{ic|~/.bashrc}}<br />
* {{ic|~/.bash_logout}}<br />
An overview of the commonly used configuration files:<br />
====/etc/profile====<br />
{{ic|/etc/profile}} is sourced by all Bourne-compatible shells upon login. It sets up an environment upon login and loads application-specific ({{ic|/etc/profile.d/*.sh}}) settings.<br />
<br />
====.profile====<br />
This file is read and sourced by bash when an interactive login shell is started.<br />
<br />
====.bashrc====<br />
The file {{ic|~/.bashrc}} is read and sourced by bash when a non-login interactive shell is started, for example, when you open a virtual console from the desktop environment. This file is useful for setting up a user-specific shell environment.<br />
<br />
===Configuration file sourcing order at startup===<br />
These files are sourced by bash in different circumstances. <br />
* if interactive + login shell → {{ic|/etc/profile}} then the first readable of {{ic|~/.bash_profile}}, {{ic|~/.bash_login}}, and {{ic|~/.profile}}<br />
**Bash will source {{ic|~/.bash_logout}} upon exit. <br />
* if interactive + non-login shell → {{ic|/etc/bash.bashrc}} then {{ic|~/.bashrc}}<br />
* if login shell + legacy mode → {{ic|/etc/profile}} then {{ic|~/.profile}}<br />
<br />
But, in Arch, by default:<br />
* {{ic|/etc/profile}} (indirectly) sources {{ic|/etc/bash.bashrc}}<br />
* {{ic|/etc/skel/.bash_profile}} which users are encouraged to copy to {{ic|~/.bash_profile}}, sources {{ic|~/.bashrc}}<br />
which means that {{ic|/etc/bash.bashrc}} and {{ic|~/.bashrc}} will be executed for all interactive shells, whether they are login shells or not.<br />
<br />
Examples of the user dotfiles can be found in {{ic|/etc/skel/}}.<br />
<br />
{{Note|legacy mode is when invoked with the name {{Ic|sh}}}}<br />
<br />
===Shell and environment variables===<br />
The behavior of bash and programs run by it can be influenced by a number of environment variable. Environment variables are used to store useful values such as command search directories, or which browser to use. When a new shell or script is launched it inherits its parent's variables, thus starting with an internal set of shell variables[http://www.kingcomputerservices.com/unix_101/understanding_unix_shells_and_environment_variables.htm ].<br />
<br />
These shell variables in bash can be exported in order to become environment variables:<br />
VARIABLE=content<br />
export VARIABLE<br />
or with a shortcut<br />
export VARIABLE=content<br />
<br />
Environment variables are conventionally placed in {{ic|~/.profile}} or {{ic|/etc/profile}} so that all bourne-compatible shells can use them.<br />
<br />
See [[Environment Variables]] for more general information.<br />
<br />
==Command line==<br />
Bash command line is managed by the separate library called [[Readline]]. Readline provides a lot of shortcuts for interacting with the command line i.e. moving back and forth on the word basis, deleting words etc. It is also Readline's responsibility to manage [[Readline#History|history]] of input commands. Last, but not least, it allows you to create [[Readline#Macros|macros]].<br />
<br />
==Aliases==<br />
[[Wikipedia:alias|alias]] is a command, which enables a replacement of a word with another string. It is often used for abbreviating a system command, or for adding default arguments to a regularly used command.<br />
<br />
Personal aliases are preferably stored in {{ic|~/.bashrc}}, and system-wide aliases (which affect all users) belong in {{ic|/etc/bash.bashrc}}.<br />
<br />
An example excerpt from {{ic|~/.bashrc}} covering several time-saving aliases:<br />
{{hc|~/.bashrc<br />
|2=<nowiki><br />
# modified commands<br />
alias diff='colordiff' # requires colordiff package<br />
alias grep='grep --color=auto'<br />
alias more='less'<br />
alias df='df -h'<br />
alias du='du -c -h'<br />
alias mkdir='mkdir -p -v'<br />
alias nano='nano -w'<br />
alias ping='ping -c 5'<br />
alias ..='cd ..'<br />
<br />
# new commands<br />
alias da='date "+%A, %B %d, %Y [%T]"'<br />
alias du1='du --max-depth=1'<br />
alias hist='history | grep' # requires an argument<br />
alias openports='netstat --all --numeric --programs --inet --inet6'<br />
alias pg='ps -Af | grep $1' # requires an argument (note: /usr/bin/pg is installed by the util-linux package; maybe a different alias name should be used)<br />
<br />
# privileged access<br />
if [ $UID -ne 0 ]; then<br />
alias sudo='sudo '<br />
alias scat='sudo cat'<br />
alias svim='sudo vim'<br />
alias root='sudo su'<br />
alias reboot='sudo reboot'<br />
alias halt='sudo halt'<br />
alias update='sudo pacman -Su'<br />
alias netcfg='sudo netcfg2'<br />
fi<br />
<br />
# ls<br />
alias ls='ls -hF --color=auto'<br />
alias lr='ls -R' # recursive ls<br />
alias ll='ls -l'<br />
alias la='ll -A'<br />
alias lx='ll -BX' # sort by extension<br />
alias lz='ll -rS' # sort by size<br />
alias lt='ll -rt' # sort by date<br />
alias lm='la | more'<br />
<br />
# safety features<br />
alias cp='cp -i'<br />
alias mv='mv -i'<br />
alias rm='rm -I' # 'rm -i' prompts for every file<br />
alias ln='ln -i'<br />
alias chown='chown --preserve-root'<br />
alias chmod='chmod --preserve-root'<br />
alias chgrp='chgrp --preserve-root'<br />
<br />
# pacman/yaourt aliases<br />
alias pac="sudo /usr/bin/pacman -S" # default action - install one or more packages<br />
alias paca="/usr/bin/yaourt -S" # default yaourt action - install one or more packages including AUR<br />
alias pacu="/usr/bin/yaourt -Syua" # '[u]pdate' - upgrade all packages to their newest version<br />
alias pacr="sudo /usr/bin/yaourt -Rs" # '[r]emove' - uninstall one or more packages<br />
alias pacs="/usr/bin/pacman -Ss" # '[s]earch' - search for a package using one or more keywords<br />
alias pacas="/usr/bin/yaourt -Ss" # '[a]ur [s]earch' - search for a package or a PKGBUILD using one or more keywords<br />
alias paci="/usr/bin/yaourt -Si" # '[i]nfo' - show information about a package<br />
alias paclo="/usr/bin/pacman -Qdt" # '[l]ist [o]rphans' - list all packages which are orphaned<br />
alias pacc="sudo /usr/bin/pacman -Scc" # '[c]lean cache' - delete all not currently installed package files<br />
alias paclf="/usr/bin/pacman -Ql" # '[l]ist [f]iles' - list all files installed by a given package<br />
alias pacexpl="/usr/bin/yaourt -D --asexplicit" # 'mark as [expl]icit' - mark one or more packages as explicitly installed <br />
alias pacimpl="/usr/bin/yaourt -D --asdeps" # 'mark as [impl]icit' - mark one or more packages as non explicitly installed<br />
<br />
# '[r]emove [o]rphans' - recursively remove ALL orphaned packages<br />
alias pacro="/usr/bin/pacman -Qtdq > /dev/null && sudo /usr/bin/pacman -Rs \$(/usr/bin/pacman -Qtdq | sed -e ':a;N;$!ba;s/\n/ /g')"</nowiki>}}<br />
<br />
==Functions==<br />
Bash also support functions. The following function will extract a wide range of compressed file types. Add the function to {{ic|~/.bashrc}} and use it with the syntax {{Ic|extract <file1> <file2> ...}}<br />
<br />
{{hc|~/.bashrc<br />
|2=<nowiki><br />
extract() {<br />
local c e i<br />
<br />
(($#)) || return<br />
<br />
for i; do<br />
c=''<br />
e=1<br />
<br />
if [[ ! -r $i ]]; then<br />
echo "$0: file is unreadable: \`$i'" >&2<br />
continue<br />
fi<br />
<br />
case $i in<br />
*.t@(gz|lz|xz|b@(2|z?(2))|a@(z|r?(.@(Z|bz?(2)|gz|lzma|xz)))))<br />
c='bsdtar xvf';;<br />
*.7z) c='7z x';;<br />
*.Z) c='uncompress';;<br />
*.bz2) c='bunzip2';;<br />
*.exe) c='cabextract';;<br />
*.gz) c='gunzip';;<br />
*.rar) c='unrar x';;<br />
*.xz) c='unxz';;<br />
*.zip) c='unzip';;<br />
*) echo "$0: unrecognized file extension: \`$i'" >&2<br />
continue;;<br />
esac<br />
<br />
command $c "$i"<br />
e=$?<br />
done<br />
<br />
return $e<br />
}<br />
</nowiki>}}<br />
<br />
{{note|[[Bash]] users should make sure extglob is enabled: {{Ic|shopt -s extglob}}, for example by adding it to the {{ic|.bashrc}}. It is enabled by default if using [[Bash#Advanced completion|Bash completion]]. [[Zsh]] users should do: {{Ic|setopt kshglob}} instead.}}<br />
Another way to do this is to install the {{AUR|unp}} package from aur which contains a perl script.<br />
<br />
Very often changing to a directory is followed by the 'ls' command to list its contents. Therefore it is helpful to have a second function doing both at once.<br />
In this example we will name it 'cl' and show an error message if the specified directory does not exist.<br />
{{hc|~/.bashrc<br />
|2=<nowiki><br />
# cd and ls in one<br />
cl() {<br />
if [ -d "$1" ]; then<br />
cd "$1"<br />
ls<br />
else<br />
echo "bash: cl: '$1': Directory not found"<br />
fi<br />
}<br />
</nowiki>}}<br />
Of course the ls command can be altered to fit your needs, for example 'ls -hall --color=auto'.<br />
<br />
More bash function examples can be found [https://bbs.archlinux.org/viewtopic.php?id=30155 here.]<br />
<br />
==Tips and tricks==<br />
===Prompt customization===<br />
The bash prompt is governed by the variable {{Ic|$PS1}}. To colorize the bash prompt, first comment out the default {{Ic|$PS1}}:<br />
#PS1='[\u@\h \W]\$ '<br />
Then add the following line:<br />
PS1='\[\e[0;31m\]\u\[\e[m\] \[\e[1;34m\]\w\[\e[m\] \[\e[0;31m\]\$ \[\e[m\]\[\e[0;32m\] '<br />
This {{Ic|$PS1}} is useful for a root bash prompt, with red designation and green console text. For details on customizing your bash prompt, see [[Color Bash Prompt]].<br />
<br />
===Auto-completion===<br />
It is useful to have the auto-complete feature (pressing {{Keypress|Tab}} key twice on the keyboard) after you type some command like sudo.<br />
<br />
To do this add a line in this format to your {{ic|~/.bashrc}} file:<br />
complete -cf your_command<br />
<br />
For example, to enable auto-complete after sudo and man:<br />
complete -cf sudo<br />
complete -cf man<br />
<br />
====Advanced completion====<br />
Despite Bash's native support for basic file name, command, and variable auto-completion, there are ways of improving and extending its reach.<br />
<br />
The {{Pkg|bash-completion}} package extends functionality by adding auto-completion to a wide range of commands and their options. Enabling advanced bash completion is quite simple, just install the following package:<br />
# pacman -S bash-completion<br />
Start a new shell and it will be automatically enabled thanks to {{ic|/etc/bash.bashrc}}.<br />
{{Note|If you added any lines similar to "complete -cf sudo" as mentioned in the previous settings and have problems with bash-completion, try removing those lines.}}<br />
<br />
{{Note|1=The normal expansions that you are used to like "$ ls file.*<tab><tab>" will not work unless you "$ compopt -o bashdefault <prog>" for all programs you want to fallback to the normal glob expansions. See https://bbs.archlinux.org/viewtopic.php?id=128471 and https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html}}<br />
<br />
====Faster completion====<br />
By appending the following into the readline initialization file ({{ic|~/.inputrc}} or {{ic|/etc/inputrc}} by default):<br />
set show-all-if-ambiguous on<br />
it is no longer necessary to hit {{Keypress|Tab}} (default binding) twice to produce a list of all possible completions (both when a partial completion is possible and when no completion is possible), as a single key-press will suffice. Alternatively, to produce such a list only when no completion is possible (i.e., not when a partial completion is possible), append the following command in lieu of the previous one:<br />
set show-all-if-unmodified on<br />
<br />
=== The "command not found" hook ===<br />
The [[pkgfile]] package includes a "command not found" hook that will automatically search the [[official repositories]] when you enter an unrecognized command. Then it will display something like this:<br />
<div style="font-family: monospace; white-space: pre; overflow: auto; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> abiword<nowiki><br />
abiword may be found in the following packages:<br />
extra/abiword 2.8.6-7 usr/bin/abiword<br />
</nowiki><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
An alternative "command not found" hook is also provided by the AUR package [https://aur.archlinux.org/packages.php?ID=52305 command-not-found], which will generate an output like the following:<br />
<br />
<div style="font-family: monospace; white-space: pre; overflow: auto; margin: 1em 3em; padding: 1em; border: 3px solid #bcd; background-color: black; color: #aaa;"><span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> abiword<br />
The command 'abiword' is been provided by the following packages:<br />
<span style="font-weight: bold">abiword</span> (2.8.6-7) from extra<nowiki><br />
</nowiki>[ <span style="color: #bb0000">abiword</span> ]<br />
<span style="font-weight: bold">abiword</span> (2.8.6-7) from staging<nowiki><br />
</nowiki>[ <span style="color: #bb0000">abiword</span> ]<br />
<span style="font-weight: bold">abiword</span> (2.8.6-7) from testing<nowiki><br />
</nowiki>[ <span style="color: #bb0000">abiword</span> ]<br />
<span style="color: #0a0">chiri</span> <span style="color: #00f">~/docs</span> <span style="color: #0f0">$</span> <span style="text-decoration: blink;">_</span></div><br />
<br />
=== Disable Ctrl+z in terminal===<br />
You can disable {{Keypress|Ctrl+z}} (pauses/closes your CLI application) feature for you CLI by wrapping your command in this script<br />
#!/bin/bash<br />
trap "" 20<br />
/path_to_your_application/<br />
example:<br />
#!/bin/bash<br />
trap "" 20<br />
/usr/bin/adom<br />
<br />
With this example script, when you accidentally press {{Keypress|Ctrl+z}} instead of {{Keypress|Shift+z}} or some other key combination while playing Adom(game) your game will not end. Nothing will happen because {{Keypress|Ctrl+z}} will be ignored.<br />
<br />
===Clear the screen after logging out===<br />
To clear the screen after logging out on a virtual terminal, append the following lines to {{ic|~/.bash_logout}}:<br />
clear<br />
reset<br />
<br />
===ASCII art, fortunes and cowsay===<br />
Along with colors, system info and ASCII symbols, Bash can be made to display a piece of ASCII art on login. ASCII images can be found online and pasted into a text file, or generated from scratch. To set the image to display in a terminal on login, place the string <br />
cat /path/to/text/file<br />
at the top of {{ic|~/.bashrc}}.<br />
<br />
Random poignant, inspirational, silly or snide phrases can also be shown. To see an example, install the {{Pkg|fortune-mod}} package from the {{Ic|extra}} repository.<br />
<br />
{{bc|1=<br />
'''<font color=red>(</font><font color=green>user@host</font><font color=red>)-(</font><font color=green>10:10 AM Wed Dec 22</font><font color=red>)'''<br />
--(</font><font color=green>~</font><font color=red>)---> </font> fortune<br />
<br/><br />
It is Texas law that when two trains meet each other at a railroad crossing,<br />
each shall come to a full stop, and neither shall proceed until the other has gone.}}<br />
<br />
To have a random phrase displayed when logging into a terminal, just set <br />
command fortune<br />
as the top line in {{ic|~/.bashrc}}.<br />
<br />
{{Note|By default, {{Ic|fortune}} displays quotes and phrases that are rather inoccuous. However, the package does contain a set of comments some will find offensive, located in {{ic|/usr/share/fortune/off}}. See the man page for more info on these.}}<br />
<br />
These two features can be combined, using the program {{Pkg|cowsay}}. Modify the line at the top of {{ic|~/.bashrc}} to read <br />
command cowsay $(fortune)<br />
<br />
or<br />
command cowthink $(fortune)<br />
<br />
<br />
The earth is like a tiny grain of sand, <br />
only much, much heavier. <br />
----------------------------------------- <br />
\ ^__^<br />
\ (oo)\_______<br />
(__)\ )\/\<br />
||----w |<br />
|| ||<br />
<br />
The ASCII images are generated by {{ic|.cow}} text files located in {{ic|/usr/share/cows}}, and all themes can be listed with the command {{Ic|cowsay -l}} These files can be edited to the user's liking; custom images can also be created from scratch or found on the net. The easiest way create a custom cow file from an image found online would be to open an existing {{ic|.cow}} file in a text editor, copy-and-paste the image from a browser and save the file as a different name. Test the custom file using<br />
<br />
# cowsay -f {{ic|cowfile}} $(fortune)<br />
<br />
This can produce some nice eye candy, and the commands used can be more complex. For a specialized example, take a look [http://bambambambam.wordpress.com/2009/07/04/futurama-ascii-with-slashdot-header-quotes-in-your-terminal/ here.] Another example, to use a random cow, random facial expression, and nicely wrap the text of long fortunes.<br />
<br />
fortune -a | fmt -80 -s | cowsay -$(shuf -n 1 -e b d g p s t w y) -f $(shuf -n 1 -e $(cowsay -l | tail -n +2)) -n<br />
<br />
________________________________________ <br />
( Fry: I must be a robot. Why else would )<br />
( human women refuse to date me? )<br />
---------------------------------------- <br />
o<br />
o<br />
o <br />
,'``.._ ,'``.<br />
:,--._:)\,:,._,.:<br />
:`--,''@@@:`...';\ <br />
`,'@@@@@@@`---'@@`. <br />
/@@@@@@@@@@@@@@@@@:<br />
/@@@@@@@@@@@@@@@@@@@\<br />
,'@@@@@@@@@@@@@@@@@@@@@:\.___,-.<br />
`...,---'``````-..._@@@@|:@@@@@@@\<br />
( )@@@;:@@@@)@@@\ _,-.<br />
`. (@@@//@@@@@@@@@@`'@@@@\<br />
: `.//@@)@@@@@@)@@@@@,@;<br />
|`. _,'/@@@@@@@)@@@@)@,'@,'<br />
:`.`-..____..=:.-':@@@@@.@@@@@_,@@,'<br />
,'\ ``--....-)=' `._,@@\ )@@@'``._<br />
/@_@`. (@) /@@@@@) ; / \ \`-.'<br />
(@@@`-:`. `' ___..'@@_,-' |/ `.)<br />
`-. `.`.``-----``--,@@.'<br />
|/`.\`' ,',');<br />
` (/ (/<br />
'''<font color=red>(</font><font color=green>user@host</font><font color=red>)-(</font><font color=green>10:10 AM Wed Dec 22</font><font color=red>)'''--(</font><font color=green>~</font>)<font color=red>)---></font><br />
<br />
{{Note|If you want a full colored cowsay-like art, the best option is {{Pkg|ponysay}}, this show full colored ponies (more than 220 at version 1.1) in you terminal (inside X11 or in TTY you have full 256 colored ponies) runing 'ponysay "command or fortune command"', the complete list of ponies are showed usind 'ponysay -l'.<br />
Exist in AUR a tool for creating more ponies (or other stuff) called {{aur|util-say-git}}, and these news archives need to be stored in $HOME/.local/share/ponysay/ponies and $HOME/.local/share/ponysay/ttyponies for desktop and TTY respectibely}}<br />
<br />
===ASCII Historical Calendar===<br />
To install [http://www.openbsd.org/cgi-bin/man.cgi?query=calendar&sektion=1 calendar] files in your {{ic|~/.calendar}} directory you will need the {{Pkg|rpmextract}} package installed. Then from your home directory, run the following:<br />
$ mkdir -p ~/.calendar<br />
$ curl -o calendar.rpm http://download.fedora.redhat.com/pub/epel/5/x86_64/calendar-1.25-4.el5.x86_64.rpm<br />
$ rpm2cpio calendar.rpm | bsdtar -C ~/.calendar --strip-components=4 -xf - ./usr/share/c*<br />
<br />
This will then print out the calendar items<br />
$ sed -n "/$(date +%m\\/%d\\\|%b\*\ %d)/p" $(find ~/.calendar /usr/share/calendar -maxdepth 1 -type f -name 'c*' 2>/dev/null);<br />
<br />
===Customise Title===<br />
<br />
The {{ic|$PROMPT_COMMAND}} variable allows you to execute a command before the prompt. For example, this will change the title to your full current working directory:<br />
<br />
export PROMPT_COMMAND='echo -ne "\033]0;$PWD\007"'<br />
<br />
This will change your title to the last command run, and make sure your history file is always up-to-date:<br />
export HISTCONTROL=ignoreboth<br />
export HISTIGNORE='history*'<br />
export PROMPT_COMMAND='history -a;echo -en "\e]2;";history 1|sed "s/^[ \t]*[0-9]\{1,\} //g";echo -en "\e\\";<br />
<br />
===Fix line wrap on window resize===<br />
<br />
When you resize your xterm in vi for example, Bash will not get the resize signal, and the text you type will not wrap correctly, overlapping the prompt.<br />
<br />
Use the following in your {{ic|/etc/bash.bashrc}} (from Debian) :<br />
# check the window size after each command and, if necessary,<br />
# update the values of LINES and COLUMNS.<br />
shopt -s checkwinsize<br />
<br />
===Bash history completion===<br />
Bash history completion bound to arrow keys (down, up):<br />
# ~/.bashrc<br />
bind '"\e[A": history-search-backward'<br />
bind '"\e[B": history-search-forward'<br />
or equivalently in {{ic|~/.inputrc}}:<br />
# ~/.inputrc<br />
"\e[A": history-search-backward<br />
"\e[B": history-search-forward<br />
More info at [[Readline#History]] and [https://www.gnu.org/software/bash/manual/html_node/Readline-Init-File-Syntax.html]<br />
<br />
===Auto "cd" when entering just a path===<br />
Bash can automatically prepend {{ic|cd }} when entering just a path in the shell. For example,<br />
$ /etc<br />
<br />
normally returns this error:<br />
bash: /etc: Is a directory<br />
<br />
Enabling this feature will instead result in this:<br />
[user@host ~] $ /etc<br />
cd /etc<br />
[user@host etc] $ pwd<br />
/etc<br />
<br />
To enable this feature, you need to enable the shell option for it. To enable this persistently, add this line to your {{ic|~/.bashrc}} file:<br />
shopt -s autocd<br />
<br />
==See also==<br />
* [http://tldp.org/LDP/abs/html/ Advanced Bash Scripting Guide] - Very good resource regarding shell scripting using bash<br />
* [http://www.gnu.org/software/bash/manual/bashref.html Bash Reference Manual] - Official reference (654K)<br />
* [http://wiki.bash-hackers.org/doku.php Bash Hackers Wiki] - Excellent Bash Wiki<br />
* [http://bashscripts.org Bashscripts.org] - Forum for bash coders.<br />
* [http://www.ibm.com/developerworks/linux/library/l-bash.html Bash Scripting by Example]<br />
* [http://www.caliban.org/bash Completion Guide]<br />
* [http://mywiki.wooledge.org/BashFAQ Greg's Wiki] - Highly recommended<br />
* [http://www.gnu.org/software/bash/manual/bash.html man page]<br />
* [http://www.grymoire.com/Unix/Quote.html Quote Tutorial]<br />
* irc://irc.freenode.net#bash - Active and friendly Internet Relay Chat channel for Bash.<br />
* http://chakra-project.org/wiki/index.php/Startup_files<br />
* [http://www.aosabook.org/en/bash.html The Bourne-Again Shell] - The third chapter of ''The Architecture of Open Source Applications''<br />
* [http://tldp.org/HOWTO/Xterm-Title-4.html How to change the title of an xterm]<br />
* [http://wiki.gotux.net/bash:arc Create and Extract Various Archives]<br />
* [http://www.gnu.org/software/bash/manual/html_node/Readline-Init-File-Syntax.html Readline Init File Syntax ]</div>Paris3200