mbrubeck / compleat

Generate command-line completions using a simple DSL.
http://limpet.net/mbrubeck/2009/10/30/compleat.html
474 stars 18 forks source link

Completion for `ls` #3

Open NV opened 14 years ago

NV commented 14 years ago

How ls.usage should look like?

$ man ls
SYNOPSIS
    ls [-ABCFGHLPRTWZabcdefghiklmnopqrstuwx1] [file ...]

$ echo "ls [-ABCFGHLPRTWZabcdefghiklmnopqrstuwx1] [file ...]" > ~/.compleat/ls.usage
$ exec bash
$ ls -↹
$ ls -ABCFGHLPRTWZabcdefghiklmnopqrstuwx1

( is a tab key)

This is not what I'm expecting. Ok, another try:

$ echo "ls [-(A|B|C|F|G|H|L|P|R|T|W|Z|a|b|c|d|e|f|g|h|i|k|l|m|n|o|p|q|r|s|t|u|w|x|1)] [<file> ...]" > ~/.compleat/ls.usage
$ exec bash
$ ls ↹
$ ls - 

Instead of file listing - added.

$ ls - ↹
1   B   F   H   P   T   Z   b   d   f   h   k   m   o   q   s   u   x   
A   C   G   L   R   W   a   c   e   g   i   l   n   p   r   t   w

Space after - should not exist.

BTW, the idea of compleat is really elegant. I like it.

mbrubeck commented 14 years ago

Thanks for the report! Strings in Compleat usage files right now are always treated as whole words/tokens. There's no way yet to do regexp-style patterns within a word. So unfortunately you need to do something this:

ls [-A|-B|-C|-F] ...

I'll see if I can solve this, either in a general way, or with a specific syntax for short (single-letter) options.