Closed Bug 1518586 Opened 4 years ago Closed 4 years ago

Autocompletion for subcommands and arguments


(Firefox Build System :: Mach Core, enhancement)

Not set


(firefox66 fixed)

Tracking Status
firefox66 --- fixed


(Reporter: ahal, Assigned: ahal)


(Blocks 1 open bug)



(2 files)

Mach has a bash completion script here:

But it only works for top level commands. It would be great if we could also auto-complete subcommands and even arguments.

I'm not familiar with bash autocompletion, but it looks like this is using the mach mach-commands command to seed the options. Maybe we could add some optional arguments to mach mach-commands, e.g:

$ mach mach-commands

$ mach mach-commands try

$ mach mach-commands try fuzzy

Then update the completion script to pass the command/subcommand into mach mach-commands if appropriate.

It would also be great if this was installed by default with mach_bootstrap if possible. istr that I tried to set this up years ago and it didn't work. Also without bootstrap it doesn't help the people who need it most since knowing it exists is already advanced knowledge.

Assignee: nobody → ahal
I was looking for a good place to put documentation for enabling the
bash completion script when I realized that the 'mach' documentation
is targeted at tool developers rather than users.

Seeing as this is the main 'mach' documentation and we want to make
'firefox-source-docs' the place to go for contribution information,
we should endeavour to target end users with this documentation.

This adds a very basic usage page which should be expanded upon, but
is better than nothing.

I changed the headers in 'index.rst' to use raw:: html so that they
don't show up in the nav bar to the left (and subsequently block the
*actually important* things from appearing).
Since we're calling into a mach command for the current completion
implementation anyway (and incurring python startup penalties), we
might as well move all the bash logic into the mach command.

The new 'mach-completion' command was created in case there are
scripts relying on the current behaviour of 'mach-commands'.

Depends on D16254
Pushed by
[mach] Add some basic usage docs r=nalexander
[mach] Implement bash completion for subcommands and arguments r=nalexander
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66

Reading the doc, I noticed the existence of this completion script. Any reason why it isn't enabled as part of the bootstrap phase?

Flags: needinfo?(ahal)

Yes, it's slow. It adds a perceptible delay to every tab press. And it's a regression because it also makes tab completing paths much slower. Many developers find this regression much more annoying than the benefits. So for now it's purely opt-in.

I had a deliverable to fix this in H2, but I'm likely going to have to drop it in favour of the test path scheduling (though we'll see, it's pretty high on my personal priority list). Bug 1519990 tracks fixing the performance. Likely by having ./mach mach-completion generate a completion script (that we'd need to periodically re-generate).

P.s, if you think you can find resources to fix it, that would be awesome :p.

Flags: needinfo?(ahal)
You need to log in before you can comment on or make changes to this bug.