[comp.mail.mush] Mush help for new users

dove@ucscg.UCSC.EDU (Ray Rischpater) (03/14/91)

As a long-time fan of mush and employee of the computer center here, I was
recently asked to do a short blurb on mush for our on-line help facilities.
I wrote the following last quarter when I had to do a talk on mush for a staff
meeting for another department; it's a sort of "brag" sheet which discusses
some of the friendly nifty reasons to use mush, and how to use it nicely
in a hurry.  I converted it from ms word format to straight text, and it's
what we show now when people ask us about mush (in addition to the man page,
of course.)

Anyways, if you like this, feel free to post it publicly on any machines you
have.  It was written for mush 7.0; I haven't looked closely at it for later
versions, although I doubt anything would be different.  Feel free to mail me
comments & suggestions; if I get enough, I'll do a revised version to post and
distribute.

Hope this helps!


----- cut here -----
			A Beginner's Guide to Mush      
    			     Ray Rischpater
			 	  CATS
			      UC Santa Cruz
			   Santa Cruz, CA 95062
  			   dove@ucscg.ucsc.edu



A Beginner's Guide to Mush by Ray Rischpater (dove@ucscg.ucsc.edu)

Introduction:  The Mail User's Shell (Mush) is an environment for
sending, receiving and manipulating e-mail, designed to supersede
csh's Mail facility.  Mush is equipped with the capability to line
wrap, provide custom headers and signatures automatically, support
a sophisticated (yet simple to use) history and scripting environment
similar to csh, neatly include/forward parts of mail during an
editing session, and many other features.  Mush is invoked in the
same way that Mail is.  To check your mailbox and work with messages
in your system mailbox, type

mush

at your system prompt.  To mail an individual or group of individuals,
type

mush soandso@machinename suandsu@machinename ...

Mush will prompt you for a subject, and then the letter, which you
conclude with control, just as with Mail.  (Note that this sequence
may change as you customize mush!) This is designed to be an
introduction to Mush using its command-line interface, and briefly
explain some of the more useful and immediate benefits of Mush.
For more information on advanced features, or the optional curses
or Suntool interfaces, refer to the man page on Mush.

First-time usage of Mush:  The first time Mush is started, it will
examine your .mailrc (assuming you have one), and make a .mushrc
in your home directory, along with a file .mushuser.  It will also
chose some defaults which make it look and act very much like mail.

Initialization of Mush:
	Mush looks in three places to find information on your
	preferences, in the following order:

MAILRC (an environment variable)
.mushrc (a file in your home directory)
.mailrc (your old .mailrc file)

Upon finding one of these items, it examines the contents, configures
itself, and then drops into the shell or send mode, depending on
whether you are examining a mailbox or mailing people.  Note that
if none of these exist, Mush resorts to its defaults and executes
normally.  These files (or the environment variable) contains
commands which Mush executes upon starting up, much as in the same
way that csh executes your .cshrc file.  Thus, to customize Mush,
you simply place the commands to set internal options (such as
headers and variables) to your preferences.  The initialization
file format is similar to that of Mail, augmented by control
structures similar to csh's.  The '#' sign, as in csh, is considered
a comment -- Mush terminates processing a line after the occurrence
of a pound sign.  Note that if a '#' is contained in single or
double quotes, it is considered a literal character and not a
commenting character.

	my_hdr Organization: Entropy International  #comment set
prompt = "#%m" # The first '#' isn't a comment.

There may be "if" conditional statements in your .mushrc to evaluate
the current running states of Mush.  This is useful, for example,
if you'd like to set Mush to wrap lines when you're mailing somebody
from the command line, yet would prefer to invoke vi to edit a
letter when using mush in its shell mode.  The structure of an if
command to perform this looks like the following:

if is_sending
	set wrapcolumn=72 else
	set autoedit endif

Mush has the following internal expressions describing  its run-time
state:

istool     True if Mush is running in tool mode on a Sun 
iscurses   True if Mush is running in curses mode 
is_shell   True after initialization (used in scripts) 
hdrs_only  True if Mush is only to display headers 
is_sending True if the user is sending
mail redirect        True if output from Mush is redirected.


Note that conditionals can also examine Mush internal variables,
such as  autoedit and wrapmargin, using the $ symbol  la csh.
Internal variables in Mush determine other operating characteristics
in the environment, and will be discussed in more detail later.
If the user is not sending mail, after executing the commands in
the initialization file, Mush reads the mail out of the specified
folder (the system spool directory if no folder is given) and builds
a list of messages.  The headers are then organized into one-line
summaries and sorted (via the sort and hdr_format variables) and
displayed.  At this point, commands may be entered by the user,
scripts may be run, and so on.  Scripts are written in the same
format as the initialization file and may use the same conditional
constructs; for more information, refer to the section Mush Scripts
in the manual page for Mush.  An example .mushrc is included at
the end of this document for reference and as an example of a
complete initialization sequence.

General Usage:  Rather than go over every command, this will
summarize some of the more useful features of mush during a session
of checking and receiving mail.  The manual page should be examined
for exhaustive details on the functionality of the command-line
interface with Mush.  If during a session with Mush, new mail
arrives, you will be notified and the mail will be added to your
system mailbox.  Among other things, this will allow   you to
immediately read new mail, without exiting Mush and re-entering
it, the way you would have to with Mail.  If you're examining
another folder, you will be notified of the new mail, but of course
it will not be appended to the folder you're working with.  You
can display any message not marked for deletion when using the
shell.  To display the message, enter the line number, or use the
print or type command, as in mail.  As also with mail, a pager
(selected by the variable pager, if set) will be invoked if the
message is longer than one screenful.  You can pick messages from
an individual, pertaining to a given subject, etc.  The general
syntax for this is:

pick switch pattern

where switch is one of the following:
 +<num>          Keeps only the first <num> messages
 -<num>          Keeps only the last <num> messages ago
<format>         Searches for messages relative to today's date
		     <format> is of the form # time, such as
                     1 week 3 days etc.
 -f              Search for messages with pattern in From: field 
 -h header       Search for pattern in header header
 -i              Ignore case while searching
 -r msg_list     Search only messages in msg_list
 -s              Search for pattern in Subject: field 
 -t              Search for pattern in To: field only
 -d date 	 Select messages sent on (or if + or  is used)
                 after or before date

Note that only one of -a, -d, -f, -h, -s, and -t can be specified
at once.  Messages marked for deletion are searched, and the whole
message is scanned unless -a, -d, -f, -h, -s, or -t is specified.
Examples of the pick command include:

pick -ago 2 weeks pick -f root@mytree pick -s meeting

A nifty feature of Mush closely related to pick is the pipe symbol.
As in csh, you can pipe the output of a command to another.  For
instance, the following finds all messages from the user doofus
and deletes them:

pick -f doofus | delete

You can send mail using Mush by listing addresses on the command
line when Mush is started, by using the mail command from within
Mush, or by replying to mail in your mailbox.  When you are sending
mail, you are in a mode where everything you type is added to the
message.  When you are done entering your message, you can type a
control-D to signify the end.  Mush recognizes the same tilde
commands as Mail does, with the following extensions (among others):

~i      Includes the current message body, bracketed by the variables
pre_indent_str and post_indent_str and indented with the variable
indent_str.  

~S[!]   Includes (doesn't include) signature at end
of message.  The variables autosign and autosign2 describe the
signature.  

~u      Up one line, allowing for primitive editing
without entering the editor.  

~:$variable     Insert the string value for variable into message.  
If variable is a boolean variable, nothing is appended regardless of its value.

~:command       Run the Mush command specified by command.  You may not use
any command which sends mail, and it's not a good idea to change folders at
this time since the current message list may be corrupted.

At this point, it's probably a good idea to discuss variables under
Mush.  Like sh and csh, Mush supports the capability to use variables
to set defaults.  We've already seen a few, such as autoedit, which
tells Mush to invoke the editor anytime a message is to be entered,
and wrapcolumn, which is a numeric variable specifying the column
at which to word-wrap words in your message.  Variables can also
store strings, such as pre_indent_str, post_indent_str, and
indent_str, used by the ~i command.  While a detailed listing of
variables is beyond the scope of this work, knowing a few variables
you can set in Mush allows you to go a long way in creating custom
messages.  Taking the example with pre_indent_str and post_indent_str,
we can do the following:

set pre_indent_str="[You said...]"
set indent_str=": "
set post_indent_str="[End of excerpt from you]"

which would cause ~i to include the text of the current message as
follows:

[You said...]
: Last week at our meeting we agreed that the cost was too high
: to be manageable.  
[End of except from you]

The variables also can have escape sequences in them, to display
certain strings.  Some of the escapes are as follows:

%n     Name of the author
%s     Subject of the message
%d     Date of the message
\n     A newline 
\t     A tab

This allows for more personal customization, such as the following:

set pre_indent_str="On %d %n wrote\nregarding %s:" 
set indent_str=")"
set post_indent_str="End of excerpt from %n"

resulting in

On Oct 20, 1990, Sandy wrote regarding expenses:
) You guys have to stop spending that much.  
End of excerpt from Sandy

Autosign and autosign2 allow for customized signatures to be included
at the end of your letter.  Concrete details can be found in the
manual page for mush, but a few examples of simple autosign values
are in order:

set autosign

tells Mush to include the file ~/.signature at the bottom of every
letter you send;

set autosign="\ -- Pat"

instructs Mush to sign each of your letters with "-- Pat" on a
blank line, and

set autosign="| fortune -s"

tells Mush to end each letter with a short fortune.  In general,
a '\' at the start of autosign to interpret its value literally,
a '|' appends the result of the command following the '|', and a
file path will be interpreted as the file in which the signature
is to be found.  Autosign2 allows a list of users to be specified
by login, site, or domain who get an alternate signature.  More
information can be found (where else?) in the manual page for Mush
under autosign and autosign2.

Similar to variables but a command is the my_hdr command,
which specifies a custom header to be used in the header
section of the message.  For example, if you execute the
following (in either your .mushrc or from the command line
in Mush)

my_hdr Organization:  Very little 
my_hdr Phone number: (408) 555-1212

in your message, your recipient would see the following headers:

From sandy Fri Nov  2 02:21:30 1990
Received: by ucscg.UCSC.EDU (5.65/1.34) id AA01174; 
  Fri, 2 Nov 90 02:21:26 -0800 Date: Fri, 2 Nov90 02:21:26 -0800 
From: sandy (Sandy Snow) 
Message-Id: <9011021021.AA01174@ucscg.UCSC.EDU>
Organization: Very little 
Phone: (408) 555-1212 
X-Mailer: Mail User's Shell (7.0.3 12/22/89) 
To: dove 
Subject Nothing in particlar
	Note that pick using the -h option can be used to search
	custom  headers as well.

Mush offers many more commands, including the facility to print
messages directly to a line printer, aliasing commands, and an
excellent help facility (which can be accessed simply by typing
help [topic]) and full command compatibility with the original Mail
program.  To learn more about its advanced features, it's best to
read the manual page provided with the program and to talk with
other mush users.

Conclusion:
	Mush is a flexible interactive evironment providing a great
	deal of control over how a user formats, reads, and
	manipulates electronic mail.  The environment provides a
	great deal of programmability, allowing for a personalized
	touch in electronic mail, while making mail simpler, quicker,
	and nicer to use.

An example .mushrc

This is dove@ucscg's .mushrc file; it gives a pretty clear example of how
the above can be used in practice.

#	Various mail aliases which are nice to have...
alias hlund hlund@scu.BITNET
alias go gretchen@mica.berkeley.edu sirkm@ssyx hermit@b dove@g salguod@b johnv@metaware.com rickd@sco.com vampire@b czmax@b opsy014@k skwak@b 
alias leslie niamh@b
alias	gueron	gueron@hydrogen.ucsc.edu		# Claire
#	The stuff we want when sending letters
set ask
set askcc
set dot
set nosave
set record=~/mbox.out
set quiet="startup"
unset verify
set wrapcolumn=72
my_hdr Organization:  Entropy International
my_hdr Notice:  I support Natural Selection.
my_hdr Phone:  (408) 459-8801 
set autosign="~/.signature"
set autosign2="*serling *ikaria *unixb *akiru *johnroc *dennie *salguod *italy  *jongull *dove: ~/.sig2"

if !is_sending
	set autoinclude
	set autoedit
	set printer="narrow"
	set mbox=~/mbox.rec
	set complete
	set hdr_format="%14n\tSub: %32s\t%W %N %M"
	set pre_indent_str="Regarding %s, %n said:\n"
	set indent_str=") "
	set post_indent_str="\n"
	set in_reply_to="%n's message pertaining to %s."
	set prompt="(%T)%u/%t& "
	set squeeze
	set unix
endif



-- 
--		Ray Rischpater			dove@ucscg.ucsc.edu
--		Cowell College, UCSC		(408) 459-8801
Water in a round glass is round, and in a square glass square.  People
			often forget that fact.

mgu@chorus.fr (Marc Guillemont) (03/14/91)

One question (not really from a beginner):

From article <13384@darkstar.ucsc.edu>, by dove@ucscg.UCSC.EDU (Ray Rischpater):

> ~i      Includes the current message body, bracketed by the variables
> pre_indent_str and post_indent_str and indented with the variable
> indent_str.  

Is there any way, when composing a message, to insert (via ~i or ~f)
messages from other folders (i.e. not from the current one), either with a
specific syntax (like ~f folder:[msg-list]) or with other commands?
--

 _ __         _ _ _   ___ 	Marc Guillemont
' )  )       ' ) ) ) /   )	Chorus syste`mes
 /--' __      / / / / __  . .	6, avenue Gustave Eiffel
/    / '     / / ( (___/_(_/_	F-78182, St-Quentin-en-Yvelines Cedex

Tel: +33 (1) 30 64 82 21	Fax: +33 (1) 30 57 00 66
E-mail: mgu@chorus.fr		or mgu%chorus.fr@mcsun.EU.net

tony@mwuk.UUCP (Tony Mountifield) (03/15/91)

In article <8398@chorus.fr> mgu@chorus.fr (Marc Guillemont) writes:
> 
> One question (not really from a beginner):
> 
> From article <13384@darkstar.ucsc.edu>, by dove@ucscg.UCSC.EDU (Ray Rischpater):
> 
> > ~i      Includes the current message body, bracketed by the variables
> > pre_indent_str and post_indent_str and indented with the variable
> > indent_str.  
> 
> Is there any way, when composing a message, to insert (via ~i or ~f)
> messages from other folders (i.e. not from the current one), either with a
> specific syntax (like ~f folder:[msg-list]) or with other commands?

How about:

	~:folder newfolder
	~i msg-list

Of course, to find out the message numbers, you may need to do something
like:
	~:pick <some-selction-specifier> | from

In between the two commands.

Tony.
-- 
Tony Mountifield.                | Microware Systems (UK) Ltd.
MAIL:  tony@mwuk.uucp            | Leylands Farm, Nobs Crook,
INET:  tony%mwuk.uucp@ukc.ac.uk  | Colden Common, WINCHESTER, SO21 1TH.
UUCP:  ...!mcsun!ukc!mwuk!tony   | Tel: 0703 601990   Fax: 0703 601991
**** OS-9, OS-9000 Real Time Systems **** MS-DOS - just say "No!" ****

schaefer@ogicse.ogi.edu (Barton E. Schaefer) (03/18/91)

In article <330@mwuk.UUCP> tony@mwuk.UUCP (Tony Mountifield) writes:
} 
} Of course, to find out the message numbers, you may need to do something
} like:
} 	~:pick <some-selction-specifier> | from

Of course, piping pick to from is almost redundant, since printing
header summaries is what pick does by default ... no-prize to anyone
who knows why I say "almost", and two no-prizes for knowing what else
you can do to get the same result.
-- 
Bart Schaefer                                           schaefer@zipcode.com
Z-Code Software Corporation                             schaefer@cse.ogi.edu