Skip to content


Subversion checkout URL

You can clone with
Download ZIP


bower install <TAB_COMPLETION> ? #93

hemanth opened this Issue · 25 comments

6 participants


It would be kool to have bash like tab completion here?

Was thinking if we can use this with compgen -W or this or something similar?


this sounds pretty awesome, interested in giving it a shot implementing it?


@fat Yes, tried a first cut couple of days back. Will give a gist soon!


@fat @sindresorhus Here is the first cut, for simplicity have avoided CLI args.

var auto = require('autocomplete');
var request = require('request');
  var data = JSON.parse(body);
  var pkgs = [];
  var ac = auto.connectAutocomplete();


  var matches ='back');


That would output :

[ 'backbone',
  'backbone-amd' ]

@hemanth Any progress?


@sindresorhus Yet to proceed on the first cut, was on a vacation. :man:


@hemanth Ok, no worries, just wanted to ping in :)


Tried the same with bower commands :

var auto = require('autocomplete');
var request = require('request');
var cmds = require('./index.js');
var cmds =  Object.keys(cmds);

var ac = auto.connectAutocomplete();

var matches ='i');

That would output something like :

[ 'install', 'info' ]

But now having issues with tab-completion here!

Until the return key is pressed we can't process the argv, is there a way out? Would be better to play with readline or something similar? Is there a way to trap key? Or should be done with bash/other auto-complete module?

Also, came across but seems like it's not working as in the example.

@sindresorhus @fat @satazor Need some suggestions please :six_pointed_star:


I have no experience with Bash autocompletion, but I know @mklabs did a prototype for Yeoman, maybe he can give some insight.


@hemanth This needs to be integrated with a postinstall script.

Basically you need to create a new bower command (e.g.: _autocomplete) and print to the stdout the autocompletion results (separated by a newline).

Then, we need to detect the type of shell in the postinstall script and react accordingly.

  • For bash, it would create a /etc/profile.d/ with the following:

    COMPREPLY=( $(bower _autocomplete "$*") )
    return 0
    complete -F _bower bower

The postinstall script should also warn the user that he needs to reload its shell to have the autocomplete.
I can make some quick example that works.

Completing this solution, a postuninstall script should also be done to remove any added files to the system.

IMPORTANT: all of this should only be done if bower was installed with -g


@satazor There seems to be some complexity invloved in handling diffrenent $SHELL, anyway it would have been more kool if node had some similar facility is in't ? /me awaits for the example.


@hemanth yes, I know that this is possible for bash but I don't know how to do it in zshell or iterm. But we could support bash initially and investigate how it's done for others later on.

I will make the example as soon as I get some free time.


@hemanth Still need the example? I think that if you follow yeomen's you are going to make it.


@hemanth I'm willing to help if you want to.


@satazor Was down with fever :crying_cat_face: @mklabs I would neva say no to helping hand! :+1:


@hemanth I'll send you something soon to review :)


@mklabs wow! ok :wolf:

@mklabs mklabs referenced this issue

Completion #191


Hey guys!

I've just noticed you're working on completition, and I must say a few things about this.

It's definitely cool to have completition on frequently used cli tools.
However, I think it's the job of your shell, not the tool you're using.

I created an oh-my-zsh plugin for bower a few months ago, you might want to check it out.
Here is the description of the plugin:
And here is the code:
It's probably can be easily ported to bash or other shells.


Hey @miklos-martin

While I understand your point, I tend to not agree.

See for the reasoning behind this. Each and every command can have a different semantic, and to really be comprehensive, you can't only rely on parsing just the help output. In the end, it's still your shells job, the scripts just acts in a "plumbing mode".


@mklabs: Thanks for the info, I didn't know that.

Then take my previous comment as a tip. I hope it helps others, as it eases my life too.


Don't get me wrong, I definitely think your zsh script is cool. I've learned a few things in there :)


This was fixed #191

@nwinkler nwinkler referenced this issue in Bash-it/bash-it

Added Bower completion #368

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.