-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bash completion Ubuntu 20.04 #25
Comments
I'm experiencing the exact same problem on Debian 11 (bullseye). With the exact same workaround of |
Wait, so Ubuntu needs |
uh. now that i reread the original post here, i'm confused as well. when i built the debian package here, lintian warned about the file in |
I understand the issue now. The problem is not the directory, The issue is that completion scripts in Though So this function could be moved to other file which are sourced ( |
yeah, so i can confirm that issue as well. the problem is the auto-loading. i wonder how other extensions / software handle this. surely (e.g.) git has some tricks to fix this? |
After a few tests, I can confirm the issue too. My other extensions have the same issue (they all install completion under In pass-otp, it works because the file is installed in |
Hm. I don't know. here the here's the complete file, in case that matters: # Use git-annex's built-in bash completion
# This is the same code output by git-annex --bash-completion-script git-annex
# This covers all commands, all options, and will never go out of date!
_git-annex()
{
local CMDLINE
local IFS=$'\n'
CMDLINE=(--bash-completion-index $COMP_CWORD)
for arg in ${COMP_WORDS[@]}; do
CMDLINE=(${CMDLINE[@]} --bash-completion-word $arg)
done
COMPREPLY=( $(git-annex "${CMDLINE[@]}") )
}
complete -o bashdefault -o default -o filenames -F _git-annex git-annex
# Called by git's bash completion script when completing "git annex"
# Translate to the "git-annex" completion above.
_git_annex() {
local CMDLINE
CMDLINE=(--bash-completion-index $(($COMP_CWORD - 1)))
local seen_git
local seen_annex
for arg in ${COMP_WORDS[@]}; do
if [ "$arg" = git ] && [ -z "$seen_git" ]; then
seen_git=1
CMDLINE=(${CMDLINE[@]} --bash-completion-word git-annex)
elif [ "$arg" = annex ] && [ -z "$seen_annex" ]; then
seen_annex=1
else
CMDLINE=(${CMDLINE[@]} --bash-completion-word $arg)
fi
done
# This is the same as __gitcomp_file_direct in git-completion.bash;
local IFS=$'\n'
COMPREPLY=( $(git-annex "${CMDLINE[@]}") )
compopt -o filenames +o nospace ||
compgen -f /non-existing-dir/ >/dev/null ||
true
} one thing I find interesting is this comment:
I think this is something in the __git_complete_command () {
local command="$1"
local completion_func="_git_${command//-/_}"
if ! __git_have_func $completion_func &&
__git_have_func _completion_loader
then
_completion_loader "git-$command"
fi
if __git_have_func $completion_func
then
$completion_func
return 0
elif __git_support_parseopt_helper "$command"
then
__git_complete_common "$command"
return 0
else
return 1
fi
} So I think that's the key thing here: the So I think to fix this properly, one must patch pass directly. |
Interestingly, the pass completion also does not properly delegate the git)
COMPREPLY+=($(compgen -W "init push pull config log reflog rebase" -- ${cur}))
;; ... so that's something that could be improved over there as well, but it's getting out of scope here. |
Turns out this is a long-known issue with the possible solution also (patch upstream pass): Now I've submitted a patch on the mailing list: Hopefully it will get merged. |
After installing from the
apt
repository on Ubuntu 20.04, completion for bash was not working.If I:
source /usr/share/bash-completion/completions/pass-update
sourced manually the file (or in.bashrc
),sudo mv /usr/share/bash-completion/completions/pass-update /etc/bash_completion.d/
then it was working.
In my understanding, completion scripts are loaded by
/usr/share/bash-completion/bash_completion
only if the completion script has the same name as the invoked command, which ispass
in our case. The completion script for pass (/usr/share/bash-completion/completions/pass
) will not source the pass-update script. If the completion function (__password_store_extension_complete_update
) isn't defined yet it won't be called.However completion scripts in
/etc/bash_completion.d/
are sourced by/usr/share/bash-completion/bash_completion
automatically.So it seems on Ubuntu 20.04
/etc/bash_completion.d/
is the good place for this script:8721eb0#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52
The text was updated successfully, but these errors were encountered: