Skip to content

Commit

Permalink
Merge pull request #2227 from fox-forks/hyperupcall-clean-completion-…
Browse files Browse the repository at this point in the history
…aliases
  • Loading branch information
seefood authored Nov 6, 2024
2 parents 0513eaf + 6d4d175 commit 15beb6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions clean_files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ lint_clean_files.sh

# completions
#
completion/available/aliases.completion.bash
completion/available/apm.completion.bash
completion/available/awless.completion.bash
completion/available/awscli.completion.bash
Expand Down
8 changes: 4 additions & 4 deletions completion/available/aliases.completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function _bash-it-component-completion-callback-on-init-aliases() {
completions=("${completions[@]##complete -* * -}") # strip all but last option plus trigger(s)
completions=("${completions[@]#complete -}") # strip anything missed
completions=("${completions[@]#? * }") # strip last option and arg, leaving only trigger(s)
completions=("${completions[@]#? }") # strip anything missed
completions=("${completions[@]#? }") # strip anything missed
#TODO: this will fail on some completions...

# create temporary file for wrapper functions and completions
Expand All @@ -40,10 +40,10 @@ function _bash-it-component-completion-callback-on-init-aliases() {
line="${line#alias -- }"
line="${line#alias }"
alias_name="${line%%=*}"
alias_defn="${line#*=\'}" # alias definition
alias_defn="${line#*=\'}" # alias definition
alias_defn="${alias_defn%\'}"
alias_cmd="${alias_defn%%[[:space:]]*}" # first word of alias
if [[ ${alias_defn} == ${alias_cmd} ]]; then
if [[ ${alias_defn} == "${alias_cmd}" ]]; then
alias_args=''
else
alias_args="${alias_defn#*[[:space:]]}" # everything after first word
Expand Down Expand Up @@ -89,7 +89,7 @@ function _bash-it-component-completion-callback-on-init-aliases() {
prec_word=\${prec_word#* }
fi
(( COMP_CWORD += ${#alias_arg_words[@]} ))
COMP_WORDS=(\"$alias_cmd\" \"${alias_arg_words[@]}\" \"\${COMP_WORDS[@]:1}\")
COMP_WORDS=(\"$alias_cmd\" \"${alias_arg_words[*]}\" \"\${COMP_WORDS[@]:1}\")
(( COMP_POINT -= \${#COMP_LINE} ))
COMP_LINE=\${COMP_LINE/$alias_name/$alias_cmd $alias_args}
(( COMP_POINT += \${#COMP_LINE} ))
Expand Down

0 comments on commit 15beb6d

Please sign in to comment.