sampsyo/beets — pull request #553 by geigerzaehler (2014-02-20 00:22:59+00:00)
Title: Add shell completion

Running `beet completion` prints a shell script that provides completion for the `beet` command. To test it run `eval "$(beet completion)"` in your shell, then try typing `beet -[TAB]`.

The script complete beets subcommands, global options, and subcommand options.

If a beets command is found on the command line it completes filenames and the subcommand's options. Otherwise it will complete global options and subcommands. If the previous option on the command line expects an argument, it also completes filenames or directories. Options are only completed if '-' has already been typed on the command line.

Note that completion only works for builtin commands and *not* for commands provided by plugins

I also included some crude testing for this. The `test/test_completion.sh` script runs tests in a shell and exit with a non-zero status code if the tests fail. It assumes that the completion script is already loaded in the executing shell.

As of now, completion only works on bash 4.1 and newer.