Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Enable BASH completion for Composer
diff --git a/composer.json b/composer.json
index 718b067..cebec32 100644
--- a/composer.json
+++ b/composer.json
@@ -27,7 +27,8 @@
"seld/jsonlint": "1.*",
"symfony/console": "~2.3",
"symfony/finder": "~2.2",
- "symfony/process": "~2.1"
+ "symfony/process": "~2.1",
+ "stecman/symfony-console-completion": "~0.3.0"
},
"require-dev": {
"phpunit/phpunit": "~3.7"
diff --git a/src/Composer/Console/Application.php b/src/Composer/Console/Application.php
index 4e2fa14..fdca3d1 100644
--- a/src/Composer/Console/Application.php
+++ b/src/Composer/Console/Application.php
@@ -225,6 +225,7 @@ class Application extends BaseApplication
protected function getDefaultCommands()
{
$commands = parent::getDefaultCommands();
+ $commands[] = new \Stecman\Component\Symfony\Console\BashCompletion\CompletionCommand();
$commands[] = new Command\AboutCommand();
$commands[] = new Command\ConfigCommand();
$commands[] = new Command\DependsCommand();
@stecman

This comment has been minimized.

Copy link
Owner Author

commented Jul 13, 2014

To get this going after patching, run a composer update, then:

$ eval `./bin/composer _completion --generate-hook`
$ ./bin/composer [tab] [tab]

or

$ alias composer="`pwd`/bin/composer"
$ eval `composer _completion --generate-hook -p composer`
$ composer [tab] [tab]
@stecman

This comment has been minimized.

Copy link
Owner Author

commented Aug 15, 2014

This can now be added without modifying Composer's code, using a (hacky) Composer plugin: Composer BASH completion plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.