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 of exec command #70

Closed
jedi4ever opened this issue Jul 24, 2016 · 5 comments
Closed

bash completion of exec command #70

jedi4ever opened this issue Jul 24, 2016 · 5 comments

Comments

@jedi4ever
Copy link

we use make a lot at work. It has nice bashcompletion for it's tasks.

Execing it with aws-vault exec <profile> make sure works great! thanks for the plugin!
But it breaks the completion.

I researched and came across _command_offsetin bash_completion.
It is used by sudo to achieve something similar.

Maybe it can inspire you :)

@lox
Copy link
Collaborator

lox commented Jul 24, 2016

Yup, I've wanted to do this for a while. Unfortunately I'm a zsh user, but I think it can be done such that it's portable.

@lox
Copy link
Collaborator

lox commented Jul 24, 2016

Apparently this is somewhat helped by the cli library we use: https://github.com/alecthomas/kingpin#bashzsh-shell-completion

@jedi4ever
Copy link
Author

@lox this build in completion will only help for the aws-vault options
afaik this will not pass commandcompletion to the execed command
for that the command offset is needed , but I guess it's a good start to hack on

@jedi4ever
Copy link
Author

I tried the build in eval "$(aws-vault --completion-script-bash)"
but it says --completion-script-bash option is not found.

I've made some progress on the completion of the exec command.

aws-vault exec profile1 -- make <TAB> now expands correctly the make tasks

I'll continue to enhance it with the aws-vault options.

# bash completion for aws-vault                             -*- shell-script -*-

_aws_vault()
{
    local cur prev words cword

    local i

    cur="${COMP_WORDS[COMP_CWORD]}"
    prev="${COMP_WORDS[COMP_CWORD-1]}"

    for (( i=1; i <= COMP_CWORD; i++ )); do
        if [[ ${COMP_WORDS[i]} == -- ]]; then
            local root_command=${COMP_WORDS[i]}
            _command_offset $i+1
            return
        fi
    done

} && complete -F _aws_vault aws-vault

@lox
Copy link
Collaborator

lox commented Jul 25, 2016

Nice! I've been working on getting the latest cli stuff into aws-vault so that we can at least use kingpin to output the above script when --completion-script-bash is passed.

segevfiner added a commit to segevfiner/aws-vault that referenced this issue Oct 30, 2018
They are based on the shell completion scripts generated by kingpin in
alecthomas/kingpin#252. Modified to complete commands after '--'.

Fixes 99designs#70
segevfiner added a commit to segevfiner/aws-vault that referenced this issue Oct 30, 2018
They are based on the shell completion scripts generated by kingpin in
alecthomas/kingpin#252. Modified to complete commands after '--'.

Fixes 99designs#70
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants