computergeneration

computergeneration on crates.io

computergeneration is a partial compgen replacement whose primary goal is to provide case-insensitive completions, since compgen doesn't seem to be able to do that. It's written in Rust, and you can install it right now:

bash cargo install computergeneration

``` $ computergeneration --help computergeneration 0.1.0 Generates completions based on a word list and a prompt.

Word list is expected to be provided via stdin, and newline-delimited.

USAGE: computergeneration.exe [FLAGS]

FLAGS: -i, --case-insensitive Whether matches should ignore case

-h, --help
        Prints help information

-V, --version
        Prints version information

ARGS: Beginning of line to complete against ```

Basic Usage

I had a sort of janky Bash completion script that looked like this with compgen:

```bash

Jump to the machine's projects directory ($PROJ) and optionally a project

inside it.

function proj() { cd "$PROJ/$1" }

function projcomplete() { COMPREPLY=( $(compgen -W "$(\ls -1 $PROJ)" "${COMPWORDS[1]}") ) return 0 } complete -F _projcomplete proj ```

I replaced it with this, using computergeneration:

```bash

Jump to the machine's projects directory ($PROJ) and optionally a project

inside it.

function proj() { cd "$PROJ/$1" }

function projcomplete() { COMPREPLY=( $(\ls -1 $PROJ | computergeneration -i "${COMPWORDS[1]}") ) return 0 } complete -F _projcomplete proj ```

Suddenly, I'm able to tab-complete project names and move into them even when I forget how they're capitalized!

This is made a lot less useful by the fact that I also use fzf-tab-completion, but it was a nice exercise.

Where did this name come from?

Imagine you spelled out "comp gen" and used tab-completion to finish each word... but you got the wrong word both times!

License

Licensed under the MIT license. See LICENSE.txt or http://opensource.org/licenses/MIT for details.