I’ve been using mutt for years and recently started using muttprofile which lets you choose certain configuration settings when you have multiple email accounts. For me a couple of things are unhandy about muttprofile. I don’t like the fact it gives out error codes and I would like an option to select a profile from a list. So I decided to build something similar in bash. The idea is to make a folder in your homedirectory which contains small sniplets of mutt configurations. Every file contains settings specific for sending mail for that account. The script can easily be changed from default locations, but in this example I will keep the defaults. Create a folder .mutt mkdir ~/.mutt You can now create a profile. I’ll do an example for a private email account. Edit the file (vi ~/.mutt/profile.private) and put in the following content: # NAME: private
# DESC: private email profile The configuration sets the headers, configures the smtp delivery I use (msmtp) and updates the statusbar. Of course you can add all kinds of other configuration items. The NAME and DESC items in the header are the same as for muttprofile. The NAME is ignored, but the DESC can be used to give a better description of the profile. When this profile is made active, a symlink is created to the profile. As the symlink always has the same name you can refer to it in the main mutt configuration. For example, if you use the c key to compose a new message in mutt, you can add the following to your main mutt configuration: macro index c "!mpn:source ~/.mutt/profile.activenm" Here mp is the name of the shellscript shown below (somewhere in your path). It is executed first, letting you select the profile you want to use. It will link the chosen profile to the ~/.mutt/profile.active. The settings in that file will be sourced and the m command is run to compose a new mail. The mp script looks like this: #!/bin/bash
#
# Select a mail profile for mutt. Simplified shellscript version
#
# 20110518 MV: Initial version I’ve used whiptail instead of dialog as it has the option to select a default menu item. That way pressing enter will keep you going on the same profile. Of course you can add loads of profiles and make the menu look different, its quite a simpel shellscript. |