Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 1.47 KB

README.md

File metadata and controls

45 lines (33 loc) · 1.47 KB

bash-complete-api

Bash command that queries bash completions.

Makes it possible to use bash completions in any shell (I'm using it for zsh).

How it works

  1. Bash is executed
  2. Desired completions are loaded
  3. Bash completion related variables are populated using specified arguments
  4. Specified bash completion function is called
  5. Generated completion is printed to STDOUT

Usage

USAGE: bash-complete-api [OPTIONS] COMPLETION_FUNCTION COMP_CWORD COMP_POINT COMP_LINE
In human language: function_to_call number_of_words cursor_position current_commandline_contents

OPTIONS: -h|--help                    Shows this help
         -w|--wordbreaks CHARS        Sets wordbreaks to CHARS
         -s|--source FILE             Sources FILE after sourcing /etc/bash_completion
         -S|--no-system-completion    Do not source /etc/bash_completion
         -d|--debug LOGFILE           Log to LOGFILE
         --                           Ends option processing

Examples

openstack does not have a completion for zsh.
This is how I used bash-complete-api to create zsh completion for openstack:

#compdef openstack

function _openstack {
    compadd -U -- $(bash-complete-api _openstack $((${CURRENT}-1)) $CURSOR "$BUFFER")
}

Issues

Feel free to create an issue.