MHPATH(1)
β¨ NAME β¨
mhpath β the little bestie that prints out full pathnames of nmh messages and folders. That's it. That's the whole job. And she does it flawlessly. π
She's part of the nmh family, version 1.8, and she lives in the General Commands Manual, section 1. Slay.
πΈ SYNOPSIS πΈ
mhpath [-help] [-version] [+folder] [msgs]
π¦ DESCRIPTION π¦
Okay so here's the vibe: mhpath takes your message list msgs, expands it, sorts it, and then writes the full pathnames of those messages to standard output β each one on its own line, separated by newlines. Clean. Tidy. Iconic.
If you don't give her any msgs at all? She outputs the current mail folder's pathname instead. And if the only argument you pass is +? She prints your nmh βPathβ β which, lowkey, is super useful in shell scripts. π«Ά
π the part where she's different from every other nmh command
Here's the thing bestie β unlike the other nmh commands, a message argument to mhpath may often be intended for writing. And because of that:
- The name βnewβ has been added to
mhpath's list of reserved message names. The others are βfirstβ, βlastβ, βprevβ, βnextβ, βcurβ, and βallβ. Thenewmessage is equivalent to the message after the last message in a folder β and equivalent to1in a folder that has no messages. β οΈ Thenewmessage may not be used as part of a message range. (Not negotiable, sorry.) - Within a message list, the following designations may refer to messages that do not exist: a single numeric message name, the single message name
cur, and (obviously) the single message namenew. Every other message designation must refer to at least one existing message, if the folder contains messages. Periodt. - An empty folder is not, in itself, an error. She's not mad. She's just chill like that. π
π the range rules (pay attention, this is the plot)
- A message number less than that of the smallest existing message in a folder is treated as if the message already exists. (Delulu? No. Intentional.)
- A message number greater than that of the highest existing message in a folder causes an βout of rangeβ error message to be displayed. π¨
- But if it's part of a range designation that contains messages that do exist, then message numbers less than the smallest β or greater than the highest β existing message in a folder are ignored. Ignored! She's unbothered.
π EXAMPLES π (the main character montage)
So the current folder is foo, it contains messages 3 5 6, and Cur is 4. Watch her work:
$ mhpath
/r/phyl/Mail/foo
$ mhpath all
/r/phyl/Mail/foo/3
/r/phyl/Mail/foo/5
/r/phyl/Mail/foo/6
$ mhpath 2001
mhpath: message 2001 out of range 1-6
$ mhpath 1-2001
/r/phyl/Mail/foo/3
/r/phyl/Mail/foo/5
/r/phyl/Mail/foo/6
$ mhpath new
/r/phyl/Mail/foo/7
$ mhpath last new
/r/phyl/Mail/foo/6
/r/phyl/Mail/foo/7
$ mhpath last-new
mhpath: bad message list last-new
$ mhpath cur
/r/phyl/Mail/foo/4
$ mhpath 1-2
mhpath: no messages in range 1-2
$ mhpath first:2
/r/phyl/Mail/foo/3
/r/phyl/Mail/foo/5
$ mhpath 1 2
/r/phyl/Mail/foo/1
/r/phyl/Mail/foo/2
See how mhpath 1-2 said no messages in range but mhpath 1 2 happily printed /r/phyl/Mail/foo/1 and /r/phyl/Mail/foo/2? Yeah. That's the range rule doing its thing. π§
π backquoted operations π
mhpath is also that girl inside backquotes:
$ cd `mhpath +inbox`
$ echo `mhpath +`
/r/phyl/Mail
β οΈ the cautionary tale (do NOT skip this one)
Because mhpath expands and sorts [msgs], this command:
mv `mhpath 501 500`
will not move 501 to 500. Quite the reverse, actually. π The sorting gets you. But:
mv `mhpath 501` `mhpath 500`
will do the trick. Two separate calls, two separate sorts, no chaos. You're welcome. π
π₯ one more error note
Out-of-range message 0 produces a different error message than large out-of-range message numbers do. But here's what matters: both cause mhpath to exit with non-zero status. So if you're scripting, check that exit code, bestie. No cap.
π FILES π
$HOME/.mh_profileβ The user profile
π PROFILE COMPONENTS π
Path:β To determine the user's nmh directoryCurrent-Folder:β To find the default current folder
π SEE ALSO π
β DEFAULTS β
+folderdefaults to the current foldermsgsdefaults to none
π CONTEXT π
None. (She keeps it simple. No state, no drama.)
And that's the whole page, gorgeous β brought to you by nmh-1.8, dated 2012-02-18. Go forth and print some pathnames. π β¨
π¦ where this page comes from
- alpine 3.24: nmh-doc 1.8-r3 Β· BSD-3-Clause
- epel 10: nmh 1.8-3.el10_1 Β· BSD
- epel 9: nmh 1.8-1.el9 Β· BSD
- fedora 43: nmh 1.8-9.fc43 Β· LicenseRef-Callaway-BSD
- fedora 44: nmh 1.8-10.fc44 Β· LicenseRef-Callaway-BSD
- nixos 26.05: nmh 1.8
- nixpkgs unstable: nmh 1.8
- opensuse-leap 16.0: nmh 1.8-bp160.1.13 Β· BSD-3-Clause
- opensuse-leap 16.0: nmh 1.8-bp160.1.13 Β· BSD-3-Clause
- opensuse-leap 16.0: nmh 1.8-bp160.1.13 Β· BSD-3-Clause
- opensuse-leap 16.0: nmh 1.8-bp160.1.13 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms