Hi all,

I've recently written a simple wrapper for Fossil with the goal of
providing an improved CLI experience and thought others might find it
useful.

The script is written in Tcl/Expect and provides the following features:

   * Command aliasing
   * Output filtering
   * A number of preconfigured aliases, filters for colouring output

Though still inchoate, you should be able to use it as you would
`fossil' on the command line.

If you're interested, feel free to clone from
http://fossil.0branch.com/fsl/home or download `fsl' directly:
http://fossil.0branch.com/fsl/artifact/f57c7ecf8c4db2a9990b40ee21e7637a1374f45e
.
The code is ISC licensed (likely overkill for such a simple script).

# Details

Out of the box, a number of filters and aliases are defined in
~/.fslrc (created on first run):

   * Aliases ('->' indicates the expansion)
      * '.'     -> 'changes'
      * 'd'     -> 'diff'
      * ','     -> 'ui'
      * 'log'   -> 'timeline'
      * 'heads' -> 'leaves'

   * Filters (all of which colour output)
      * 'diff'
         * 'fsl d'
      * 'log_entry'
         * 'fsl leaves', 'fsl timeline'
      * 'status'
         * 'fsl changes', 'fsl status', 'fsl timeline', 'fsl add',
           'fsl rm', 'fsl addremove'

You can see a summary of these definitions using the `fsl wrapper'
pseudo-command:

  $ fsl wrapper
  Aliases: . d , log heads
  Filters: changes status timeline add rm addremove leaves d

The configuration file is a Tcl script: you can define `proc's (for
helper functions) and employ them in your filters. Definitions will
end up in the `config::fslrc' namespace so you needn't worry about
clobbering predefined functions. Since the script makes heavy use of
dictionaries, it requires Tcl >= 8.5.

Alias declarations are trivial; their second argument can be a
bareword or quoted string, thereby allowing expansions to provide
switches if required, e.g.

  alias log      timeline
  alias history {timeline -n 100}

Filters are named, allowing them to be referenced elsewhere in your
configuration script. Their structure is:

  filter <internal name> <list of commands to filter> <body>

If you filter on a fossil command like `diff', aliases of this command
(by default, `d') will also be filtered. Conversely, filtering on an
alias (`d'), leaves its expansion (`diff') untouched. Also note that
more than one filter may apply to a given command: under the default
configuration, the timeline will be filtered by both `status' and
`log_entry'.

A filter body can reference the current output line via the implicitly
defined $line variable. By way of example, here's the `log_entry'
filter:

  filter log_entry {leaves timeline} {
      if {[regexp "^=== .* ===" $line]} {
          coloured blue $line
      } else {
          regsub -all {\[[A-Fa-f0-9]+\]} $line [coloured yellow &]
      }
  }

Useful functions defined by the script are:

   * `coloured' (for colouring output)
   * `alias?'
   * `filter?'
   * `empty?' and `prefix?' (simple utility functions)

Patches, criticisms, suggestions etc. are welcome.

Best,
Marc
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

Reply via email to