Pass the aliased command as an argument to _filedir_xspec

pull/1503/head
Taro Sato 2020-02-22 16:20:40 -08:00
parent bf5dd87f33
commit fe26adf7ac
1 changed files with 4 additions and 1 deletions

View File

@ -63,6 +63,9 @@ function alias_completion {
local compl_func="${new_completion/#* -F /}"; compl_func="${compl_func%% *}" local compl_func="${new_completion/#* -F /}"; compl_func="${compl_func%% *}"
# avoid recursive call loops by ignoring our own functions # avoid recursive call loops by ignoring our own functions
if [[ "${compl_func#_$namespace::}" == $compl_func ]]; then if [[ "${compl_func#_$namespace::}" == $compl_func ]]; then
if [[ $compl_func == _filedir_xspec ]]; then
compl_func_args=$alias_cmd
fi
local compl_wrapper="_${namespace}::${alias_name}" local compl_wrapper="_${namespace}::${alias_name}"
echo "function $compl_wrapper { echo "function $compl_wrapper {
(( COMP_CWORD += ${#alias_arg_words[@]} )) (( COMP_CWORD += ${#alias_arg_words[@]} ))
@ -70,7 +73,7 @@ function alias_completion {
(( COMP_POINT -= \${#COMP_LINE} )) (( COMP_POINT -= \${#COMP_LINE} ))
COMP_LINE=\${COMP_LINE/$alias_name/$alias_cmd $alias_args} COMP_LINE=\${COMP_LINE/$alias_name/$alias_cmd $alias_args}
(( COMP_POINT += \${#COMP_LINE} )) (( COMP_POINT += \${#COMP_LINE} ))
$compl_func $compl_func $compl_func_args
}" >> "$tmp_file" }" >> "$tmp_file"
new_completion="${new_completion/ -F $compl_func / -F $compl_wrapper }" new_completion="${new_completion/ -F $compl_func / -F $compl_wrapper }"
fi fi