github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

mbrubeck / compleat

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 59
    • 5
  • Source
  • Commits
  • Network (5)
  • Issues (2)
  • Downloads (0)
  • Wiki (2)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (1)
    • master ✓
  • Tags (0)
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Generate command-line completions from simple usage descriptions. — Read more

  cancel

http://limpet.net/mbrubeck/2009/10/30/compleat.html

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Adding escaping of : characters in suggestions 
cpennington (author)
Mon Dec 21 08:15:14 -0800 2009
Matt Brubeck (committer)
Mon Dec 21 09:26:01 -0800 2009
commit  8f8cbd9e1aec62555607c380e3e81eaf26bfa4c0
tree    1a6159b8c928befa883a2d36fdae3e7197d86dbb
parent  bcfa83634884bc3858cdbc76d8555a679144361b
compleat /
name age
history
message
file .gitignore Loading commit data...
file Completer.hs Mon Dec 21 09:26:01 -0800 2009 Adding escaping of : characters in suggestions ... [cpennington]
file README.markdown Wed Nov 11 09:54:26 -0800 2009 Fix a bad typo in the documentation. [Matt Brubeck]
file Setup.lhs
file TODO.txt Thu Oct 29 17:33:53 -0700 2009 Call external shell commands for completions. [Matt Brubeck]
file Tokenize.hs Thu Oct 29 06:13:22 -0700 2009 More code documentation. [Matt Brubeck]
file Usage.hs Thu Oct 29 17:33:53 -0700 2009 Call external shell commands for completions. [Matt Brubeck]
file compleat.cabal Thu Oct 29 17:33:53 -0700 2009 Call external shell commands for completions. [Matt Brubeck]
file compleat.hs
file compleat_setup Thu Oct 29 07:26:21 -0700 2009 Fix handling of alternate names for commands. ... [Matt Brubeck]
directory examples/ Mon Nov 16 13:48:57 -0800 2009 darcs usage file by Josef Svenningsson. [Matt Brubeck]
README.markdown

Compleat

Generate tab completion for any shell command by specifying its usage in a familiar manpage-like format. For example, a usage specification for top(1):

top [-b | -c | -H | -i | -s | -S | -d <delay> | -n <num> | -p <pid> ...] ... ;
top (-h|-v)

The only supported shell at the moment is bash.

Installation

Get the source code: git clone git://github.com/mbrubeck/compleat.git

Next, install GHC and Parsec. OS X or Windows users, download the Haskell Platform. (Mac OS X 10.6 may require a workaround for 64-bit compatibility.) Debian/Ubuntu users, run: sudo aptitude install libghc6-parsec2-dev

To install Compleat in your system, run:

./Setup.lhs configure
./Setup.lhs build
sudo ./Setup.lhs install

(This will install to /usr/local by default. The "configure" command takes a --prefix=PATH option to change the location, and --user to install as a non-root user.)

To enable compleat in your shell, add the following line to your .bashrc. (Adjust the path if you configured with a custom prefix.)

source /usr/local/share/compleat-1.0/compleat_setup

and install your .usage files in a directory named /etc/compleat.d or ~/.compleat:

sudo mkdir /etc/compleat.d
sudo cp examples/* /etc/compleat.d

Restart your shell to begin using completions:

exec bash

Type top and then press Tab a few times to see the example files in action.

Syntax

A usage file contains commands and definitions, separated by semicolons.

A command consists of a command name followed by a pattern. The command name can be any atom. If there is more than one command in the file, compleat will attempt to match each of them against the input line.

An atom consists of letters, numbers, and any of the characters -_/@=+.,:, or any string enclosed in double quotes with C/Java-style backslash escapes.

The following are valid patterns:

  • Any atom matches itself: foo matches the string foo. "x\\y" matches the string x\y.
  • a b matches a followed by b.
  • a b | c matches either a b or c.
  • [a] matches zero or one occurrences of a.
  • a ... matches one or more occurrences of a.
  • [a] ... matches zero or more occurrences of a.

Use parentheses to group patterns:

  • a (b | c) matches a followed by either b or c.
  • (a | b) ... matches a or b followed by any number of additional a or b.

Patterns may also include variables:

  • name = value; defines a new variable. The name can be any atom, and the value can be any pattern. Then <name> in a pattern refers to the value as a sub-pattern.

  • name = !command; defines a variable that uses a shell command to generate suggested completions. The shell command should print one suggested completion per line. The $COMP_LINE and $COMP_CWORD environment will contain the input line and the current word being completed.

  • If no value is defined for name, then the pattern <name> will match any word.

Copyright

Copyright (c) 2009 Matt Brubeck

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server