(M)  s i s t e m a   o p e r a c i o n a l   m a g n u x   l i n u x ~/ · documentação · suporte · sobre

  Next Previous Contents

7. Interesting Macros for Mutt

Mutt is highly configurable and its working mode can be modified in a very flexible manner if the configuration variables inside .muttrc are well configured.

Here you can see some macros that help you to generate signed messages avoiding the PGP/MIME standard, to send it to receipts that don't support this type of signed messages following the PGP/MIME standard, and to edit the alias file and reload it without exiting Mutt (this last macro is not related to PGP/GnuPG, it is presented only as an example to show the macro power in Mutt).

It is possible to tell Mutt the key bindings you want to use with PGP/GnuPG. Even when some of this options are yet configured, we can change it or add others easily modifiying the configuration file.

7.1 Signing on the message body without using PGP/MIME with PGP5

Before existing PGP/MIME, the signature in a message was included in the message body. This is a very common form of sending signed messages in many mail user agents.

If we want to sign like this, we have two options, leave the MIME type of the message or modify it as application/pgp.

To implement this two forms of signing in Mutt, we will add the following lines to the ~/mutt.varios/mutt.macros file. Previously, we have to set this option file path in the .muttrc main configuration file (see Optional configuration files):

macro   compose \Cp     "F/usr/bin/pgps\ny"
macro   compose S       "F/usr/bin/pgps\ny^T^Uapplication/pgp; format=text; x-action=sign\n"

and now, pressing <Ctrl>p or S we can include the signature into the message part that has the cursor on it, just before send the message.

7.2 Signing on the message body without using PGP/MIME with GnuPG

As in the previous case, but with GnuPG. The macros are:

macro   compose \CP     "Fgpg --clearsign\ny"
macro   compose \CS     "Fgpg --clearsign\ny^T^Uapplication/pgp; format=text; x-action=sign\n"

7.3 Modifying the alias file and reloading it

With this macro included in ~/mutt.varios/macros.mutt you can edit with vi (changing the line you can use other editor) the alias file without exiting Mutt pressing <Alt>a.

macro   index   \ea     "!vi ~/Mail/.alias\n:source =.alias\n"

7.4 More macro examples

The next listing has been obtained from Roland Rosenfeld and it shows macros to change the default signing/encrypting software and to sign without PGP/MIME with GnuPG:

# ~/Mail/.muttrc.macros
# keyboard configuration file for Mutt-i
# copied, modified and translated from the original:
#
################################################################
# The ultimative Key-Bindings for Mutt                         #
#                                                              #
# (c) 1997-1999 Roland Rosenfeld <roland@spinnaker.rhein.de>   #
#                                                              #
# $ Id: keybind,v 1.36 1999/02/20 19:36:28 roland Exp roland $ #
################################################################
#
# To use it, add the next line to ~/.muttrc:
# source ~/Mail/.muttrc.macros
#

# Generic keybindings
# (for all the Mutt menus, except the pager!)
# With the next three we can change the encrypting default selected software:

# <ESC>1 to use GnuPG
macro   generic \e1     ":set pgp_default_version=gpg ?pgp_default_version\n"\
"Switch to GNU-PG"

# <ESC>2 to use PGP2
macro   generic \e2     ":set pgp_default_version=pgp2 ?pgp_default_version\n"\ 
"Switch to PGP 2.*" 

# <ESC>5 to use PGP5
macro   generic \e5     ":set pgp_default_version=pgp5 ?pgp_default_version\n"\
"Switch to PGP 5.*"

#NOTE: Be careful with the last backspace at the end of the previous
macros. If you write that line and the next in the same line, do not write
it.

# index, OpMain, MENU_MAIN
# (Main menu)
# The next macro only runs from the main menu (the one that appears when
# you starts Mutt). The keys <CTRL>K permit us to extract the public keys
# from a message if it has (this is known because it has the K letter in
# the message line):

macro  pager   \Ck     ":set pipe_decode pgp_key_version=pgp2\n\e\ek:set pgp_key_version=pgp5\n\e\ek:set pgp_key_version=gpg\n\e\ek:set pgp_key_version=default nopipe_decode\n"\ "Extract PGP keys to PGP2, PGP 5, and GnuPG keyrings"


# pager, OpPager, MENU_PAGER
# (Pager menu)
# It permits the same operations that previous, with the same key combinations,
# but in this case from the pager menu:

macro   pager   \e1     ":set pgp_default_version=gpg ?pgp_default_version\n"\
"switch to GNUPG"

macro   pager   \e2     ":set pgp_default_version=pgp2 ?pgp_default_version\n"\
"switch to PGP 2.*"

macro   pager   \e5     ":set pgp_default_version=pgp5 ?pgp_default_version\n"\
"switch to PGP 5.*"


# compose, OpCompose+OpGerneric, MENU_COMPOSE
# (Compose menu)
# The next operations are used from the compose menu.
# That is, after you have composed your message and you close it to send it,
# just before pressing the "Y" key that allows us to send it to the MTA.

# In this case, we create a menu that appears when you press "P".
# The options in this menu are going to be bound to MENU_PGP. This are the
# main use options (encryption and signing).

bind    compose p       pgp-menu

# As many programs can't use PGP/MIME (especially from M$), the <CTRL>P key
# will allow us to sign "as in the old times" (Application/PGP):

macro   compose \CP     "Fgpg --clearsign\ny"

# The next, <CTRL>S will allow us to sign using PGP/MIME with the private key
# that we have defined as default. This macro is not necesary, as we can
# do the same from the "P" menu:
macro   compose \CS     "Fgpg --clearsign\ny^T^Uapplication/pgp; format=text; x-action=sign\n"

You can add more macros, and some other are yet configured as default in newer versions of Mutt. Some other options include:

  • <CTRL>K (extract public keys from a message)
  • <ESC>K (adjunt a public key to a message)
  • <CTRL>F (when using the key phrase to sign or decrypt a message, it is still in memory. With this you can delete it from memory)
  • etc...

To see what other options are activated, you must go to the help menu (?) from the menu where you were.


Next Previous Contents