Home > Blockchain >  (Git)Bash programmable completion with short '-...' and long '--...' options
(Git)Bash programmable completion with short '-...' and long '--...' options

Time:11-17

I created a completion function inspired by How to Create a Custom Bash Completion Script (which has some obvious errors but I corrected these) and in a newer version on GitHub.

bash_completion_test

#!/bin/bash
#
# bash_completion_test
#
# from https://maskedbyte.com/how-to-create-a-custom-bash-completion-script/
#  and https://github.com/SumuduLansakara/custom-bash-completion-script/blob/master/completer.sh
#

echo 'Begin bash_completion_test...'

# -------------------------------
# Generic hierarchical completion

# test definitions
_args=(add list remove)
list_args=(student teacher)
list_student_args=(age grade name)
list_student_grade_args=(-a -o --another --option)
list_teacher_args=(name)


function generic_hierarchical_completion_test() {

    local arguments word_list_ptr word DEBUG
    
    log='bash_completion_test.log'
    echo -n '␃           
  • Related