recentpopularlog in

kme : programmablecompletion   6

linux - Bash completion for path in argument (with equals sign present) - Stack Overflow
Check out the definition of COMP_WORDBREAKS in your environment to see why '--arg=<TAB>' (maybe) isn't working.
bash  programmablecompletion  tabcompletion  completion  maybesolution  workaround 
august 2019 by kme
Programmable Completion (Bash Reference Manual)
Finally, any prefix and suffix specified with the -P and -S options are added to each member of the completion list, and the result is returned to the Readline completion code as the list of possible completions.


See
bash  completion  tabcompletion  programmablecompletion  shellscripting  solution 
august 2019 by kme
An introduction to bash completion: part 2
I created a script and I use bash_completion, but I cannot figure out how to allow the completion of "--name=value1 --name=value2" (the "=" sign in the middle stop any other completion, and I tried to play with suffixes/prefixes without any success :s


This works:

<code class="language-bash">case "$cur" in
-t*)
cur=${cur/-t}
COMPREPLY=( $(compgen -W "${_tables[*]}" -P "-t" \
-- "$cur" ) )
return 0
;;
--table=*)
cur=${cur/--table=}
COMPREPLY=( $(compgen -W "${_tables[*]}" -P "--table=" \
-- "$cur" ) )
return
;;
*)
COMPREPLY=( $(compgen -W "${_opts[*]}" -- "$cur") )
return
;;
esac</code>
bash  programmablecompletion  tabcompletion  shellscripting  fuckina  solution 
august 2019 by kme
compgen: An Awesome Command To List All Linux Commands - nixCraft
<code class="language-bash">########################################
# Task: show all the bash built-ins
########################################
compgen -b
########################################
# Task: show all the bash keywords
########################################
compgen -k
########################################
# Task: show all the bash functions
########################################
compgen -A function</code>
bash  programmablecompletion  completion  tabcompletion  compgen  reference  newbie 
august 2019 by kme
bash - How can I prevent unsupported 'shopt' options from causing errors in my .bashrc? - Unix & Linux Stack Exchange | https://unix.stackexchange.com/
But if you really dislike redirecting the error away, you can use the completion mechanism to perform introspection. This assumes that you don't have antiquated machines with bash ≤ 2.03 that didn't have programmable completion.
<code class="language-bash">
shopt_exists () {
compgen -A shopt -X \!"$1" "$1" >/dev/null
}
if shopt_exists direxpand; then
shopt -s direxpand
fi
</code>

This method avoids forking, which is slow on some environments such as Cygwin. So does the straightforward 2>/dev/null, I don't think you can beat that on performance.
bash  configfile  shellscripting  shopt  programmablecompletion  tabcompletion  schooling  solution 
february 2019 by kme

Copy this bookmark:





to read