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

Feature Request: Tab completion for entries #54

Closed
rothgar opened this issue Nov 7, 2014 · 24 comments
Closed

Feature Request: Tab completion for entries #54

rothgar opened this issue Nov 7, 2014 · 24 comments

Comments

@rothgar
Copy link

rothgar commented Nov 7, 2014

Please add tab completion for entries. Similar to pass which has tab completion for folders and entries. When dealing with 100s of entries it is pretty essential to make using the cli useful.

It'd also be great if tab completion worked with fuzzy logic so names didn't have to be exact.

Please see pass' bash completion for more details, but I'm sure you guys can figure out a way. ;)

@bcopeland
Copy link
Contributor

The one tricky thing about this is that we might not be able to look into the blob while logged out, so I guess we'd just fail to complete if the key is not available in the agent (rather than prompt). But generally, I agree it'd be a handy feature.

For another take on fuzzy matching see this pull request: #52 -- comments and/or patches welcome on what form that should take.

@rothgar
Copy link
Author

rothgar commented Nov 7, 2014

I think it would be OK to assume you need to be logged in with the agent running for this to work. I would probably just change my timeout env variable to make tab completion more useful

@bcopeland
Copy link
Contributor

This needs some work (please feel free to hack on it!), but here is some basic completion support:

fd599fa

The patterns fed to grep aren't escaped properly, so e.g. completing on "(" doesn't work correctly.

@RowanKaag
Copy link

Is this merged yet? Doesn't seem to work on OSX 10.11.1

@bcopeland
Copy link
Contributor

No, it is still unmerged, and still somewhat broken due to improper escaping.

@bcopeland
Copy link
Contributor

Merged now.

@RowanKaag
Copy link

excuse my (probably stupid) question, but in what context was the merge supposed to work? I might be entering wrong commands to try the autocomplete, but typing lpass log; and then pressing tap, isn't that supposed to autocomplete to login?

@bcopeland
Copy link
Contributor

You need to load it into your bash session, e.g.:

source contrib/lpass_bash_completion

@RowanKaag
Copy link

I've installed via Homebrew, which lpass returns /usr/local/bin, can't find any shell scripts in there. Nor can I find any in /usr/local/Cellar/. Any idea how I could add a line in .zshrc to make it a default for every new shell?

@bcopeland
Copy link
Contributor

It's in the github repository; as I didn't do the homebrew build, I'm not sure where it might have contrib scripts.

If you are using zsh, it probably will not work for you. If using bash, you could just add the source /path/to/lpass_bash_completion to your ~/.bashrc. Unfortunately I don't use zsh so I don't know much about how completion works for it.

@ghost
Copy link

ghost commented Aug 12, 2016

To anyone else that comes across this from google and is using homebrew:

find $(brew --prefix) -type f -name lpass

Mine was in:

/usr/local/Cellar/lastpass-cli/1.0.0/share/bash-completion/completions/lpass

@samhh
Copy link

samhh commented Jan 16, 2017

@timja This worked for me with 1.0.0, but on 1.1.1 there's no bash-completion directory. Just me or you as well?

@timja
Copy link

timja commented Jan 16, 2017

@samhh Missing for me to. I hadn't noticed because the brew update kept around the old version

$ find $(brew --prefix) -type f -name lpass
/usr/local/Cellar/lastpass-cli/1.0.0/bin/lpass
/usr/local/Cellar/lastpass-cli/1.0.0/share/bash-completion/completions/lpass
/usr/local/Cellar/lastpass-cli/1.1.1/bin/lpass

@bcopeland
Copy link
Contributor

bcopeland commented Jan 16, 2017 via email

@timja
Copy link

timja commented Jan 16, 2017

I believe the location it should actually be going into is:

 $(brew --prefix)/etc/bash_completion.d

@ssalonen
Copy link

ssalonen commented Jan 7, 2018

There was some discussion for zsh autocompletion.

For the record, bash completions are supported in zsh using bashcompinit. For more information, consult these instructions:

https://stackoverflow.com/questions/3249432/i-have-a-bash-tab-completion-script-is-there-a-simple-way-to-use-it-from-zsh

For me the following seems to work in ~/.zshrc (fedora installation)

# support bash autocompletion
# https://stackoverflow.com/questions/3249432/i-have-a-bash-tab-completion-script-is-t
autoload bashcompinit
bashcompinit

if [[ -f /usr/share/bash-completion/completions/lpass ]]; then
        source /usr/share/bash-completion/completions/lpass
fi

@rderik
Copy link

rderik commented Mar 5, 2018

Just as an FYI, I got my pull-request to the Homebrew formula for lastpass-cli to now install bash_completion and completion for fish by default when you install it.

So if you have already installed lastpass-cli you'll have to manually reinstall because the version of the formula wasn't changed.

Homebrew/homebrew-core#24745 (comment)

Hope that helps

@tbigueres
Copy link

tbigueres commented Apr 25, 2018

Hi @bcopeland

Any news on this ?
I have the same issue, on mac OS High Sierra and lastpass CLI 1.3.0.

Is there any way to get auto-completion for mac ?
Thanks

@rderik
Copy link

rderik commented Apr 25, 2018

Hi @tbigueres,

If you install it through homebrew you should now have the auto-completion by default.

If you previously had lastpass cli installed the version didn't change so it doesn't apply if you do a update you'll have to manually uninstall and reinstall it again for it to get the auto-completion.

Have you tried that?

@tbigueres
Copy link

Hey @rderik

Thanks for the quick answer.
Indeed I tried

brew reinstall lastpass-cli

But it did not work. I still cannot use autocompletion.
If you have any idea it would be awesome.

@rderik
Copy link

rderik commented Apr 25, 2018

I just try it now I did:
brew uninstall lastpass-cli
then
brew install lastpass-cli
Then open a new bash terminal and
lpass log[tab]
and got
login logout

What version of bash are you on?
echo $BASH_VERSION

@tbigueres
Copy link

I'm on ZSH,
A colleague of mine has the same issue and is on the following bash :

echo $BASH_VERSION 3.2.57(1)-release

@tbigueres
Copy link

I tried again the brew uninstall and reinstall, but still nothing happens.
@rderik

@rderik
Copy link

rderik commented Apr 25, 2018

Oh yea,

When I did the new formula I didn't include the zsh autocomplete, only bash and fishshell :S
That's why is not working for you on zsh. I'll have to check if there is a zsh autocomplete and add it to the formula and ask for a pull request for it. I'll update you if I figure that out.

And for your friend it might be a good idea to update his bash, that is an outdated bash maybe the autocomplete only works on newer versions you can ask him to try a newer version of bash the one in homebrew is: 4.4.12 tell him to try that one and let me know if it works for him.

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

8 participants