Mutt Configuration Based on Current Hostname

596 views Asked by At

I am specifically writing this from the perspective of running Mutt from multiple hosts, but a single source-code-controlled configuration file. Leave it to the devops side that "all" host configurations are being kept adequately in-sync.

So, basically, I want a specific mailbox configuration, effectively based on host type, but more generically, based solely on the hostname command. Essentially, I want the default mailbox to be "correct" for a given host (generally /var/mail/$user for Linux hosts), but I have already defined hotkeys for Mailbox 1-3 that default to hotkeys (basically F2, F# and F4 are the IMAPS mailboxes, and the default is the local system default).

How would you set this up? Currently, I can switch between mailboxes with the proper hotkeys. But, how do I base muttrc "decisions" based on the hostname in which mutt has been run?

1

There are 1 answers

1
Jakub Jindra On BEST ANSWER

This solution should work with mutt and neomutt. The idea is to put host specific configuration in separate files and source them in main configuration file. See example below.

Files:

  • ~/.neomutt/neomuttrc main config file
  • ~/.neomutt/neomuttrc.host1 host specific config file
  • ~/.neomutt/neomuttrc.host2 host specific config file

Content of ~/.neomutt/neomuttrc

# Your main confing file. Here ale all the shared settings. 
# …
# source host specific config
source ~/.neomutt/neomuttrc.`hostname`