Skip to content

Completion

Kevin Zhuang edited this page Jan 27, 2021 · 3 revisions

dotbare currently support completion for zsh and bash. There are two types of completion, you could either enable command line completion for dotbare commands such as dotbare <TAB> dotbare fadd <TAB> or you could enable git commands completions.

Note: if you choose to use the git commands completion, there will be a lot of limitations because git completion script is not aware of $DOTBARE_DIR and $DOTBARE_TREE, hence for example when you do dotbare add <TAB>, git doesn't know where to look for modified files and will result in searching modified files in the current directory.

zsh

The completion mechanism are currently included in the dotbare.plugin.zsh file but is not activated by default. After sourcing/loading dotbare through either source dotbare.plugin.zsh or through plugin manager, you can then invoke the completion function to activate them. There are two completion functions which are listed below, only one of them should be used, they are not intended to be invoked together.

Note: Both completion function has to be called after loading compinit, if you are confused, put the completion function call near bottom of your .zshrc.

autoload -U compinit && compinit
_dotbare_completion_cmd

# If you use OhMyZsh, call it after loading the main OhMyZsh script
source $ZSH/oh-my-zsh.sh
_dotbare_completion_cmd

_dotbare_completion_cmd

Enable the completion for dotbare and it's subcommands. No extra actions required if you aliased dotbare.

_dotbare_completion_cmd

_dotbare_completion_git

Enable the completion for git commands. No extra actions required if you aliased dotbare.

_dotbare_completion_git

bash

The completion mechanism are currently included in the dotbare.plugin.bash file but is not activated by default. After sourcing dotbare.plugin.bash, you can invoke the completion function to activate them. There are two completion functions which are listed below, only one of them should be used, they are not intended to be invoked together.

_dotbare_completion_cmd

Enable the completion for dotbare and it's subcommands.

Arguments:

  • $1: the command name that you want to enable completion, useful when you alias dotbare to other names, optional.
_dotbare_completion_cmd

Lets say we aliased dotbare to config for everyday usage.

_dotbare_completion_cmd config

_dotbare_completion_git

Enable the completion for git commands.

Note: this function depends on git completion for bash to be activated. I found this wiki to be quite helpful if you are struggling with git completion activation for bash.

Arguments:

  • $1: the command name that you want to enable completion, useful when you alias dotbare to other names, optional.
_dotbare_completion_git

Lets say we aliased dotbare to config for everyday usage.

_dotbare_completion_git config
Clone this wiki locally