<commit_before>ruby-complete
=============

Ruby-complete is a Ruby interface to the command completion functionality of Bash (essentially the `complete`
and `compgen` bash builtins -- see `man bash` for more info). It is useful if you want to make a bash
completion script but want to avoid writing actual bash code.

Installation
------------

First, you'll need to pick two different directories -- one for a couple of executables you'll download, and
one for any ruby completion scripts you write. You have to pick the first yourself; I like `$HOME/scripts/`
for this purpose (it should be in your path). The second will default to `$HOME/ruby-completion-scripts/`. In
our example, we'll suppose we want something different: `$HOME/scripts/completion`.

First, edit your `.bashrc` to specify `$RUBY_COMPLETE_DIR`, the home for your ruby-complete scripts:

    export RUBY_COMPLETE_DIR="$HOME/scripts/completion"

(Make sure to `source ~/.bashrc` afterwards). Now change to the chosen scripts directory and run my handy
installer script:

    $ cd $HOME/scripts
    $ curl https://github.com/cespare/ruby-complete/raw/master/install.bash | bash

This should install the executable scripts into `$HOME/scripts/` and put an example completion script in
`$HOME/scripts/completion/`. Finally, you'll want to get the completion in every shell you open; put this in
`.bashrc`:

    source $HOME/scripts/ruby-complete.bash

(Remember to change the appropriate paths if you want to install to a location other than `$HOME/scripts/`.)

The installer script will automatically register one ruby-complete script for you: the auto-complete for
`completion.rb` itself. If you source `ruby-complete.bash` manually (or open a fresh terminal), you should be
able to type

    $ completion.rb <TAB>

and see three choices auto-completed for you: `init`, `register`, and `unregister`.

Usage
-----

The basic idea is that in order to have auto-completion for the command `foo`, you have to create `foo.rb` in
the directory specified by `$RUBY_COMPLETE_DIR`. After you register the command `foo` with `completion.rb`,
your completion script will be called whenever you tab-complete after typing `foo`. The completion for
`completion.rb` is hence `$RUBY_COMPLETE_DIR/completion.rb.rb`. The best way to understand how to write ruby
completion scripts is to look at this example.

Registering and unregistering a command with completion.rb is simple:

    $ completion.rb register foo
    $ completion.rb unregister foo
<commit_msg>Pointed out a feature in the readme<commit_after>ruby-complete
=============

Ruby-complete is a Ruby interface to the command completion functionality of Bash (essentially the `complete`
and `compgen` bash builtins -- see `man bash` for more info). It is useful if you want to make a bash
completion script but want to avoid writing actual bash code.

Installation
------------

First, you'll need to pick two different directories -- one for a couple of executables you'll download, and
one for any ruby completion scripts you write. You have to pick the first yourself; I like `$HOME/scripts/`
for this purpose (it should be in your path). The second will default to `$HOME/ruby-completion-scripts/`. In
our example, we'll suppose we want something different: `$HOME/scripts/completion`.

First, edit your `.bashrc` to specify `$RUBY_COMPLETE_DIR`, the home for your ruby-complete scripts:

    export RUBY_COMPLETE_DIR="$HOME/scripts/completion"

(Make sure to `source ~/.bashrc` afterwards). Now change to the chosen scripts directory and run my handy
installer script:

    $ cd $HOME/scripts
    $ curl https://github.com/cespare/ruby-complete/raw/master/install.bash | bash

This should install the executable scripts into `$HOME/scripts/` and put an example completion script in
`$HOME/scripts/completion/`. Finally, you'll want to get the completion in every shell you open; put this in
`.bashrc`:

    source $HOME/scripts/ruby-complete.bash

(Remember to change the appropriate paths if you want to install to a location other than `$HOME/scripts/`.)

The installer script will automatically register one ruby-complete script for you: the auto-complete for
`completion.rb` itself. If you source `ruby-complete.bash` manually (or open a fresh terminal), you should be
able to type

    $ completion.rb <TAB>

and see three choices auto-completed for you: `init`, `register`, and `unregister`. Further tabbing will give
completion on sub-commands.

Usage
-----

The basic idea is that in order to have auto-completion for the command `foo`, you have to create `foo.rb` in
the directory specified by `$RUBY_COMPLETE_DIR`. After you register the command `foo` with `completion.rb`,
your completion script will be called whenever you tab-complete after typing `foo`. The completion for
`completion.rb` is hence `$RUBY_COMPLETE_DIR/completion.rb.rb`. The best way to understand how to write ruby
completion scripts is to look at this example.

Registering and unregistering a command with completion.rb is simple:

    $ completion.rb register foo
    $ completion.rb unregister foo

{'fraction_non_alphanumeric': 0.08663269306154449, 'fraction_numerical': 0.0, 'mean_word_length': 4.271694214876033, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4498515', 'n_tokens_mistral': 1414, 'n_tokens_neox': 1314, 'n_words': 667}