As of be
0.3, bash now has support for tab-completion on both Windows, Linux and OSX.
$ be activate
$ be in [TAB][TAB]
hulk spiderman superman
$ be in spid[TAB][TAB]
$ be in spiderman
...
be activate
drops you into a subshell where tab-completion has been enabled. It does this by sourcing a bash-script called _autocomplete.sh
in your be
installation directory. For extended use, you can also source this yourself, which will enable you to get tab-completion without using be activate
. To do this, add this to your .bashrc
file, or equivalent.
. /path/to/be/_autocomplete.sh
Now whenever you launch bash, you'll have tab-completion out of the box!
There are three levels of completion happening when you hit tab, based on the number of arguments currently active.
- 0 arguments, list all projects under the current working directory
- 1 argument, list contents of the project's
inventory.yaml
- 2+ arguments, list directory contents from your template
Level 3 is the most sophisticated, as it breaks apart the given template for an item in your inventory, and lists the content as far ahead as it is given arguments.
For example, consider the following tempate.
asset: "{cwd}/{0}/assets/{1}/tasks/{2}
Given 2 arguments, the template is able to expand up until {1}
. Hitting tab at this point will list the potential candidates for {2}
.
$ be in hulk bruce [TAB][TAB]
animation rigging lighting lookdev
This works for any amount of arguments.
asset: "{cwd}/{0}/assets/{1}/tasks/{2}/{3}/private/{user}/{4}
Tab-completion works great on Windows. In fact it was primarily developed on Windows. But as the native shell doesn't support tab completion beyond directory names, an alternative had to be found. Any bash-like shell should work, the be
tab-completion was tested and developed with MSYS2 - a minimal bash environment for Windows.
Further plans are in the works to also enable tab-completion for Powershell, and Cmd via Clink.
The first two levels work in any configuration, but the third level depends on arguments appearing linearly.
# Supported
asset: "{0}/{1}/{2}"
# Not supported
asset: "{0}/{2}/{1}"
This is because it is difficult to determine completion for {1}
without first knowing {2}
. This is hopefully addressed in a future version, but might incur a performance and usage penalty as it would mean to list all possible combinations of {1}
at every possible combination of {2}
, resulting in an exponential increase of possible completions and increased disk use.
To work around this issue, you can simply provide a topic in an order more suitable for your template. For example, given a template {cwd}/{0}/{2}/{1}
, you could instead produce {cwd}/{0}/{1}/{2}
and pass arguments differently.
replace
$ be in hulk bruce modeling --enter
with
$ be in hulk modeling bruce --enter