MHPATH(1mh)
π NAME π
mhpath β bestie, this one prints the full pathnames of your nmh messages and folders. That's it, that's the whole job, and it does it flawlessly. π
πΈ SYNOPSIS πΈ
mhpath [-help] [-version] [+folder] [msgs]
β¨ DESCRIPTION β¨
Okay so here's the tea β: mhpath takes your message list msgs, expands it and sorts it, then writes the full pathnames of those messages to standard output, separated by newlines. One per line, clean, iconic.
If you don't specify any msgs at all? Then mhpath just outputs the current mail folder's pathname instead. And if the only argument you give is +, you get your nmh "Path" printed out β which is genuinely so useful in shell scripts, no cap. π«Ά
Now, here's the thing that makes mhpath different from every other nmh command: a message argument to mhpath may often be intended for writing. Because of that:
- The name
newhas been added tomhpath's list of reserved message names β the others beingfirst,last,prev,next,cur, andall. Thenewmessage is equivalent to the message after the last message in a folder, and it's equivalent to1in a folder with no messages. Important: thenewmessage may not be used as part of a message range. - Within a message list, these 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. - An empty folder is not, in itself, an error. Periodt. β¨
A message number less than that of the smallest existing message in a folder is treated as if the message already exists. A message number greater than that of the highest existing message in a folder causes an out of range error message to be displayed. π
And if it's part of a range designation that contains messages that do exist, message numbers less than the smallest β or greater than the highest β existing message in a folder are simply ignored. Slay.
π¦ Examples, bestie π¦
The current folder foo contains messages 3 5 6. Cur is 4.
$ 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
mhpath is also lowkey perfect for backquoted operations:
$ cd `mhpath +inbox`
$ echo `mhpath +`
/r/phyl/Mail
Because mhpath expands and sorts [msgs]. the command
mv `mhpath 501 500`
to will not move 501 to 500; quite the reverse. But
mv `mhpath 501` `mhpath 500`
will do the trick. π (iykyk)
π¨ Out-of-range message0produces a different error message than large out-of-range message numbers. But both causemhpathto exit with non-zero status. Both. Every time. Don't forget it.
π 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
Okay that's the whole page, bestie β this one came from nmh-1.8, dated 2012-02-18, and it lives as MHPATH(1mh) in the manual. Go print some pathnames, you absolute main character. πβ¨π
π¦ where this page comes from
- debian trixie: nmh 1.8-3
- ubuntu noble: nmh 1.8-1build4
- ubuntu questing: nmh 1.8-3
- ubuntu resolute: nmh 1.8-4
- ubuntu stonking: nmh 1.8-4build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms