Created to toy with zsh completion for bb’s new tasks feature.
A simpler version of the feature implemented in this repo can be achived by adding the following to your zshrc. (From the Babashka book.)
_bb_tasks() {
local matches=(`bb tasks |tail -n +3 |cut -f1 -d ' '`)
compadd -a matches
_files # autocomplete filenames as well
}
compdef _bb_tasks bb
bb.edn examples:
- Antq bb.edn example (copied into the
bb.edn
in this repo)
Zsh completion help:
- Zsh completion script guide - this guide in particular is very useful!
- Zsh completion blog post
Something like the following is typical to get zsh completion working (see the first few paragraphs here for reference):
# add completion files to fpath
fpath=(~/.zsh/completion $fpath)
# initialize completion system
autoload -Uz compinit && compinit -i
Completion for bb requires a zsh file in /.zsh/completion/_bb
(or wherever you
append your fpath
).
See ./_bb
and ./bb_task_completion.clj
for a working implementation.
This repo was implemented as a proof of concept, and is not at all intended as a final product for bb-based completion. However if you want to try it, something like this could work as a manual install process.
# clone this repo to ~/russmatney/bb-task-completion
ln -s ~/russmatney/bb-task-completion/bb_task_completion.clj ~/.zsh/bb_task_completion.clj
ln -s ~/russmatney/bb-task-completion/_bb ~/.zsh/completion/_bb
- What’s the expected installation process for bb users?
We can probably get people to add a `source <(some-bb-command)` line to do the work
- Where should the
bb_task_completion.clj
script/logic live? Right now the task uses a hard-coded helper script to parse the bb.edn and format a string. Maybe this should live somewhere in the babashka repo itself?As implemented, users will need to install two scripts, which is not ideal.
- Completion for the rest of the bb cli options?