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 autocompletion doesn't work #159

Open
chshersh opened this issue Nov 30, 2022 · 4 comments
Open

Bash autocompletion doesn't work #159

chshersh opened this issue Nov 30, 2022 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@chshersh
Copy link
Owner

I'm trying to configure autocompletion for tool-sync. Unfortunately, it doesn't work on my Ubuntu 20.04 and bash shell. I'm trying to add the suggested line to .bashrc and ~/.bash_profile (I also made sure that I have bash-completion installed).

I tried specifying the following lines. But nothing works for me:

eval "$(tool completion bash)"
eval "$(tool completion bash --rename tool)"
`eval "$(tool completion bash)"`
`eval "$(tool completion bash --rename tool)"`
source <(tool completion bash)
source <(tool completion bash --rename tool)

So some investigation is required to fix this. Maybe it's just me. I'll have a look at the completion package and see if anything needs to be done or how to make it work.

On top of that, I can see, this probably happens because by default, the tool completion command uses the tool-sync name.

complete -F _tool-sync -o bashdefault -o default tool-sync

It would be great if tool was used by default (maybe there's a way to do this in the autocompletion package we use?). Otherwise, documentation should change to always suggest the --rename flag.

@chshersh chshersh added the bug Something isn't working label Nov 30, 2022
@chshersh chshersh added this to the v0.3.0: Auto milestone Nov 30, 2022
@MitchellBerend
Copy link
Collaborator

I can take a look at this when I get home. I also recently found out using an aliased command keeps the autocomplete working like the original command, so maybe its a good idea to remove the rename flag if that is the source of the issue.

@MitchellBerend
Copy link
Collaborator

complete -F _tool-sync -o bashdefault -o default tool-sync

Took a quick look at this, it seems the get_name command takes the name from the Cargo.toml.

This change
image

Produces this print out

...
                *)
                    COMPREPLY=()
                    ;;
            esac
            COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
            return 0
            ;;
    esac
}

complete -F _alskdjhfasdkjlfh -o bashdefault -o default alskdjhfasdkjlfh

@MitchellBerend
Copy link
Collaborator

$ lsb_release
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04 LTS
Release:	22.04
Codename:	jammy

This is in my .bashrc

eval "$(tool-sync completion bash --rename tool-sync 2> /dev/null)"

This works on both my ubuntu machines. The std err needs to be redirected since it will print the instructions on start up. This is also something that needs to be fixed.

As for the name that gets used when the rename flag is not passed, its currently using the name defined in the Cargo.toml but it can of course be hard coded by using a constant in the src/lib.rs instead of calling the get_name method.

@MitchellBerend
Copy link
Collaborator

@chshersh are you still experiencing problems?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants