Contents

The Rules File

Format of a rule

Defining rules for `ah-tty':

Comment lines
begin with `#' and are ignored.
Rule lines
are of the form: `:levels regexp'
Hint text
Any line not of the form of a rule line is taken as the hint text for the preceding rule line.

Levels are a list of digits (0-7) marking which "help level" this rule will match. The idea behind help levels is that as users gain more experience they will increase their help level and cut down the number of patronizing messages they receive. Currently, the supplied `ah-tty.conf' only uses levels 0 and 1.

Regexp is the extended POSIX regular expression that the command typed by the user must match before the hint is displayed.

In the case where more than one rule matches the current line, only one hint at a time will be displayed, in the order they appear in the file. Each hint will only be displayed once per prompt, that is, it won't match again until the user hits Return.

Kinds of rules

There are typically 4 types of entries:

  1. The command & its options
  2. A list of commands that start with that letter
  3. A suggestion to use some other command
  4. A description on how to use certain patterns (regex)

I recommend that you go from the most general to the most specific

The start of the regex pattern for a command should be something like:

	(^|[|\;])[[:space:]]*

This makes sure to match the start of the a command line, after a pipe or a start of a new command. It also recognizes spaces that the user may use for readability. But it makes sure that it is a command, not some option or file name used as part of another command. (Yes, that regular expression prefix is hideous, ugly, and generally silly looking.)

The most complicated rule

:= (^|[|\;])[[:space:]]*mv[[:space:]]+([^-|\;&[:space:]][^|\;&[:space:]]*)[^-|\;&]*[[:space:]][^-|\;&]*\2([|;&)]|$)

That is the most complicated rule in `ah-tty''s database, atleast at this moment. Laboratory animals contracted several new forms of extreme indigestion during testing of that rule.

For all its bluster, the rule is meant to catch a fairly straight forward type of command line. Here are some examples:

	mv foobar.c foobar.bak
        mv foobar.c -i foobar.bak
        mv -i foobar.c foobar.bak

The rule watches for the `mv' command, ignores the commnand flags and other options. It does notice the file names, especially when the filenames are very similar.

If `ah-tty' spots a command that matches this rule, it will print the following helpful hint:

Using `mv' and braces to renaming files:
 `mv' fixbold{5,6}   Renames the file `fixbold5' to `fixbold6'.  Useful to fix typos
 `mv' fixbold{,bak}  Renames `fixbold' to `fixbold.bak'

Markup in the help text

There are some simple markup rules that are used to provide visual hints to the user


Author: Randall Maastop