github-carapace-bin-938.progcomp-with-desc.bash (1355B)
1 # (C) 2022, Koichi Murase <myoga.murase@gmail.com> 2 # 3 # File: blesh-contrib/config/github-carapace-bin-938.completion-desc.bash 4 # Referece: https://github.com/rsteube/carapace-bin/issues/938#issuecomment-1046219977 5 6 _comp_cmd_test1() { 7 if [[ ${BLE_ATTACHED-} ]]; then 8 # If ble.sh is in the attached state. 9 10 # Change the menu style to "desc" for the current completion 11 bleopt complete_menu_style=desc 12 13 # Generate filename or directory name (The description is automatically 14 # generated from the filename for "file"). 15 ble/complete/cand/yield file 'file.txt' 16 17 # Generate words with description. 18 ble/complete/cand/yield word 'my-word' 'This is a description for my-word.' 19 20 # Generate option with OPTARG indicated in the list. In the third argument 21 # $'OPTION\x1cOPTARG\x1cSUFFIX\x1cDESCROPTION', FS ($'\x1c') is used to 22 # separate OPTION, OPTARG indicator, SUFFIX that is inserted after inserted 23 # the unique completion, and DESCRIPTION 24 ble/complete/cand/yield mandb '--option' $'--option\x1c=<something>\x1c=\x1cThis is a description for the option' 25 26 else 27 # If ble.sh is not loaded or is in the detached state, just generate 28 # candidates for the default progcomp of Bash. 29 30 COMPREPLY+=(file.txt) 31 COMPREPLY+=(candidate) 32 COMPREPLY+=(--option) 33 34 fi 35 } 36 complete -F _comp_cmd_test1 test1