2020-06-14 23:42:11 +02:00
|
|
|
_ldapsaisie()
|
|
|
|
{
|
2020-06-23 18:20:28 +02:00
|
|
|
# Retrieve cur, words and cword variables by using _get_comp_words_by_ref helper
|
|
|
|
# and excluding "=" char as break-word
|
|
|
|
local cur words cword
|
|
|
|
_get_comp_words_by_ref -n "=" cur words cword
|
|
|
|
|
2021-08-25 18:02:37 +02:00
|
|
|
# Retrieve COMPREPLY using bash_autocomplete ldapsaisie CLI command
|
2020-06-23 18:24:44 +02:00
|
|
|
COMPREPLY=( $(ldapsaisie bash_autocomplete ${cword} -- ${words[@]}) )
|
2020-06-23 18:20:28 +02:00
|
|
|
|
|
|
|
# If current word to complete contain '=' and if it's a word-break char
|
|
|
|
# Note: This method was inspired by __ltrim_colon_completions helper.
|
|
|
|
if [[ $cur == *=* && $COMP_WORDBREAKS == *=* ]]; then
|
|
|
|
# Remove equal_word prefix from COMPREPLY items
|
|
|
|
local equal_word=${cur%"${cur##*=}"}
|
|
|
|
local i=${#COMPREPLY[*]}
|
|
|
|
while ((i-- > 0)); do
|
|
|
|
COMPREPLY[i]=${COMPREPLY[i]#"$equal_word"}
|
|
|
|
done
|
|
|
|
fi
|
2020-07-06 17:53:54 +02:00
|
|
|
# If only one answer and it ending by "=", do not add space
|
|
|
|
if [[ ${#COMPREPLY[@]} -eq 1 ]] && [[ ${COMPREPLY[0]} == *= || ${COMPREPLY[0]} == *=\' || ${COMPREPLY[0]} == *=\" ]]; then
|
|
|
|
compopt -o nospace
|
|
|
|
fi
|
2020-06-14 23:42:11 +02:00
|
|
|
}
|
|
|
|
complete -o default -F _ldapsaisie ldapsaisie
|