Skip to content

Command that returns bash completion for a specific line - output can be used to complete in other shells

License

Notifications You must be signed in to change notification settings

curusarn/bash-complete-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

Command that returns bash completion for a specific line - output can be used to complete in other shells

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published