Bash completion for particle-cli

I was looking through the GitHub issues for particle-cli and I found this feature request looking for tab completion so I whipped up a bash completion file for particle-cli using my recently acquired knowledge.

Here is my repository for the tab completion file:

@Dave, @KyleG , @mdma, I’ve tried to make my code as elegant as possible, with good indentation and logical ordering of conditions.

3 Likes

Hi @nrobinson2000,

That’s awesome! Yay! So excited to try this out. :slight_smile: Is this something we can incorporate into the CLI directly, or have it automatically generated somehow?

cc @jvanier

Thanks!
David

2 Likes

To use the completion it just needs to be placed in the /etc/bash_completion.d/ directory on Linux, or the /usr/local/etc/bash_completion.d directory on macOS. On Linux the completion will be loaded automatically, but on macOS you need to source the completion file in .bashrc or your preferred file.

Automatic generation would be very cool, but if the completion has already been created it wouldn't take too much time to just add another case for each new command.

2 Likes

Automatic Install:

You can install the completion using the install script:

$ bash <(curl -sL https://git.io/vQWZD)

Also, @Dave, @KyleG, would this earn me the Level 3 Particle Badge?

1 Like

Let me look into this for you!

1 Like

Congrats!

2 Likes

Bump. Hopefully everyone who needs this will find it.

Update:

I’ve developed some Python scripts to automatically generate the bash completion script by examining the output from the particle help tree.

The particle-cli completion script is now up to date and can be easily regenerated. Writing Python code to generate Bash code was a fun challenge.

2 Likes