Skip to content
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 #137

Open
hoxu opened this issue Jan 18, 2021 · 4 comments
Open

Bash completion #137

hoxu opened this issue Jan 18, 2021 · 4 comments

Comments

@hoxu
Copy link

hoxu commented Jan 18, 2021

Is bash completion (on Debian) supposed to work out of box?

As far as I understand /usr/share/bash-completion/bash_completion should contain magic to load the right completion under /usr/share/bash-completion/completions/, and this works for pass, but /usr/share/bash-completion/completions/pass-otp does not seem to be automatically loaded.

source /usr/share/bash-completion/completions/pass-otp works.

Should this work out of box? Or should adding that line to bash profile scripts be documented?

@ghost
Copy link

ghost commented Mar 6, 2021

Not quite as technical as hoxu, but I think we're having the same issue (me on Ubuntu 20.04).

In layman's terms;
With pass you can give the first few letters of the gpg password file name, then use Tab and like straight bash it will auto-complete as far as it can.

But with pass otp no such Tab completion is present.

Adding Tab completion to pass otp would make it much quicker and more usable, well, just as quick and usable as pass.

@bedwardly-down
Copy link

I second this. Although, upon installing through Gentoo's portage system, this error message shows up:

 * Problems with installed bash completions were found:
 *
 *      pass-otp: does not define any completions (failed to source?).
 *
 * For more details on installing bash-completions, please see:
 * https://wiki.gentoo.org/wiki/Bash/Installing_completion_files
 *

It installs version 1.2.0 but my assumption is that something changed with bash-completion between bash releases but I'm not 100% sure on that.

@m4lvin
Copy link

m4lvin commented Oct 4, 2021

Should this work out of box? Or should adding that line to bash profile scripts be documented?

Source'ing that files also enables completion for me, but I think it should work out of the box, because /usr/share/bash-completion/completions/pass from pass itself contains code at the end which is supposed to activate completion for all pass extensions. See https://git.zx2c4.com/password-store/tree/src/completion/pass.bash-completion#n128

# To add completion for an extension command define a function like this:
# __password_store_extension_complete_<COMMAND>() {
#     COMPREPLY+=($(compgen -W "-o --option" -- ${cur}))
#     _pass_complete_entries 1
# }
#
# and add the command to the $PASSWORD_STORE_EXTENSION_COMMANDS array
if [[ " ${PASSWORD_STORE_EXTENSION_COMMANDS[*]} " == *" ${COMP_WORDS[1]} "* ]] && type "__password_store_extension_complete_${COMP_WORDS[1]}" &> /dev/null; then
	"__password_store_extension_complete_${COMP_WORDS[1]}"
fi

Also, the issue here seems to be a duplicate of #28 or vice versa ;-)

raindev added a commit to raindev/dotfiles that referenced this issue May 29, 2023
The completion file is supposed to be loaded out of the box but is not:
tadfisher/pass-otp#137
@quentinmit
Copy link

I stumbled on this while trying to debug missing completion for pass otp. I don't actually think there's anything wrong with pass-otp.bash.completion, nor is there anything wrong with the upstream bash-completion package. It's pass's own bash completion code that is wrong - as far as bash-completion is concerned, pass is the command that's being run, not pass-otp. pass.bash-completion needs to trigger loading of pass-otp.bash.completion by calling _completion_loader pass-otp. See how e.g. the git completion does it:

__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
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants