knife bash completion – with fixed environments autocomplete

Steven Danna has written the best knife bash completion script that I’ve seen for use with managing chef servers and the chef software by opscode.

Update: Steven has now made an update so this is working!

There was always one little thing wrong with it though:

knife environment edit (etc) would not autocomplete – it would give an error

The error was:

-bash: _chef_environments: command not found

The solution is pretty simple – you just need to edit the script and transpose two letters that were a typo from the file:


should actually be:


The difference is hard to spot but it’s key.

Two other scripts for knife completion (that I don’t like as much) are this one by avishai-ish-shalom and a spinoff by vindimy – I think they are slower and not as user friendly.

If you use zsh instead of bash there is also a zsh knife plugin which is part of oh-my-zsh that seems pretty good.

Related Posts:

  • No Related Posts
This entry was posted in Server Administration, Tech Tips and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *