Changing MH Directory Name

[previous] [next] [table of contents] [index]

By default, MH names your mail directory Mail (note the capital M) and puts it under your home directory. You can actually name this directory anything and put it anywhere on the filesystem. (It doesn't have to be in or under your home directory, but it should be someplace that you have permission to create new files and write.) For instance, you can "hide" the MH mail directory by putting a period (.) before its name. This means it won't clutter an ls listing of your home directory (unless you use ls -a, of course).

To change the name, change the Path: entry in your MH profile. By default, your MH directory name is Mail. So you should have this single Path: entry:

Path: Mail
If your MH directory doesn't exist yet, MH will see your Path: and create it in the right place when you run your first MH command. If the directory already exists and you change the Path:, you'll need to move your directory. (If you're changing the directory name but not the location in the filesystem, you can use a command like mv oldname newname. If you want to move the directory someplace else, such as a subdirectory, you may need a command like tar to move your directory and preserve any links you've made.)

Here are rules for locating your MH directory. For this example, let's see what a user named Walt could do. His home directory is /u/walt.

One problem with putting your MH directory on another filesystem is that the link named @ which repl makes can't be created from a different filesystem. There's a C shell alias below that checks your current directory as you run repl. If you aren't on the same filesystem as the MH directory, the alias uses the C shell pushd command to push the MH directory onto your directory stack. After you've replied, you can popd back to your previous directory. (Many Bourne-type shells don't have directory stacks. You could adapt this alias to use a shell function and a shell variable to save your old directory location.)
alias repl 'if ($cwd !~ /u/*) pushd /u/walt; \repl'
(That alias uses a simple-minded test: it checks the name of the first-level directory. If the filesystem with your MH directory has more than one top-level directory, the alias will use pushd more often than it needs to. You might want to use a more sophisticated test.)

Let's say that Walt installs that alias; his MH directory is under /u/walt. He wants to reply to a message while his current directory is /usr/local/system, which isn't on the /u filesystem:

% repl -noanno 23
/u/walt /usr/local/system
   ...Walt replies...
% popd

[Table of Contents] [Index] [Previous: International Character Support] [Next: Setting Access Permissions for Other Accounts]

Revised by Jerry Peek. Last change $Date: 1999/10/10 05:14:05 $

This file is from the third edition of the book MH & xmh: Email for Users & Programmers, ISBN 1-56592-093-7, by Jerry Peek. Copyright © 1991, 1992, 1995 by O'Reilly & Associates, Inc. This file is freely available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see the file copying.htm.

Suggestions are welcome: Jerry Peek <>