old-www/HOWTO/Mutt-GnuPG-PGP-HOWTO-7.html

190 lines
7.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>Mutt-i, GnuPG and PGP Howto: Interesting Macros for Mutt</TITLE>
<LINK HREF="Mutt-GnuPG-PGP-HOWTO-8.html" REL=next>
<LINK HREF="Mutt-GnuPG-PGP-HOWTO-6.html" REL=previous>
<LINK HREF="Mutt-GnuPG-PGP-HOWTO.html#toc7" REL=contents>
</HEAD>
<BODY>
<A HREF="Mutt-GnuPG-PGP-HOWTO-8.html">Next</A>
<A HREF="Mutt-GnuPG-PGP-HOWTO-6.html">Previous</A>
<A HREF="Mutt-GnuPG-PGP-HOWTO.html#toc7">Contents</A>
<HR>
<H2><A NAME="s7">7. Interesting Macros for Mutt</A></H2>
<P><EM>Mutt</EM> is highly configurable and its working mode can be modified in a
very flexible manner if the configuration variables inside <CODE>.muttrc</CODE>
are well configured.
<P>Here you can see some macros that help you to generate signed messages
avoiding the <EM>PGP/MIME</EM> standard, to send it to receipts that don't
support this type of signed messages following the <EM>PGP/MIME</EM>
standard, and to edit the alias file and reload it without exiting
<EM>Mutt</EM> (this last macro is not related to <EM>PGP/GnuPG</EM>, it is
presented only as an example to show the macro power in <EM>Mutt</EM>).
<P>It is possible to tell Mutt the key bindings you want to use with
<EM>PGP/GnuPG</EM>. Even when some of this options are yet configured, we
can change it or add others easily modifiying the configuration file.
<P>
<H2><A NAME="sec-app-pgp"></A> <A NAME="ss7.1">7.1 Signing on the message body without using PGP/MIME with PGP5</A>
</H2>
<P>Before existing <EM>PGP/MIME</EM>, 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.
<P>If we want to sign like this, we have two options, leave the <EM>MIME</EM>
type of the message or modify it as <CODE>application/pgp</CODE>.
<P>To implement this two forms of signing in <EM>Mutt</EM>, we will add the
following lines to the <CODE>~/mutt.varios/mutt.macros</CODE> file.
Previously, we have to set this option file path in the <CODE>.muttrc</CODE> main
configuration file (see
<A HREF="Mutt-GnuPG-PGP-HOWTO-6.html#sec-opcion">Optional configuration files</A>):
<P>
<BLOCKQUOTE><CODE>
<PRE>
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"
</PRE>
</CODE></BLOCKQUOTE>
<P>and now, pressing <CODE>&lt;Ctrl&gt;p</CODE> or <CODE>S</CODE> we can include the
signature into the message part that has the cursor on it, just before
send the message.
<P>
<H2><A NAME="sec-app-gpg"></A> <A NAME="ss7.2">7.2 Signing on the message body without using PGP/MIME with GnuPG</A>
</H2>
<P>As in the previous case, but with GnuPG. The macros are:
<P>
<BLOCKQUOTE><CODE>
<PRE>
macro compose \CP "Fgpg --clearsign\ny"
macro compose \CS "Fgpg --clearsign\ny^T^Uapplication/pgp; format=text; x-action=sign\n"
</PRE>
</CODE></BLOCKQUOTE>
<P>
<H2><A NAME="ss7.3">7.3 Modifying the alias file and reloading it</A>
</H2>
<P>With this macro included in <CODE>~/mutt.varios/macros.mutt</CODE> you
can edit with <EM>vi</EM> (changing the line you can use other editor) the
alias file without exiting <EM>Mutt</EM> pressing <CODE>&lt;Alt&gt;a</CODE>.
<P>
<BLOCKQUOTE><CODE>
<PRE>
macro index \ea "!vi ~/Mail/.alias\n:source =.alias\n"
</PRE>
</CODE></BLOCKQUOTE>
<P>
<H2><A NAME="ss7.4">7.4 More macro examples</A>
</H2>
<P>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:
<P>
<BLOCKQUOTE><CODE>
<PRE>
# ~/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 &lt;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:
# &lt;ESC>1 to use GnuPG
macro generic \e1 ":set pgp_default_version=gpg ?pgp_default_version\n"\
"Switch to GNU-PG"
# &lt;ESC>2 to use PGP2
macro generic \e2 ":set pgp_default_version=pgp2 ?pgp_default_version\n"\
"Switch to PGP 2.*"
# &lt;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 &lt;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 &lt;CTRL>P key
# will allow us to sign "as in the old times" (Application/PGP):
macro compose \CP "Fgpg --clearsign\ny"
# The next, &lt;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"
</PRE>
</CODE></BLOCKQUOTE>
<P>You can add more macros, and some other are yet configured as default in
newer versions of Mutt. Some other options include:
<P>
<UL>
<LI>&lt;CTRL&gt;K (extract public keys from a message)</LI>
<LI>&lt;ESC&gt;K (adjunt a public key to a message)</LI>
<LI>&lt;CTRL&gt;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)</LI>
<LI>etc...</LI>
</UL>
<P>To see what other options are activated, you must go to the help menu (?)
from the menu where you were.
<P>
<HR>
<A HREF="Mutt-GnuPG-PGP-HOWTO-8.html">Next</A>
<A HREF="Mutt-GnuPG-PGP-HOWTO-6.html">Previous</A>
<A HREF="Mutt-GnuPG-PGP-HOWTO.html#toc7">Contents</A>
</BODY>
</HTML>