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

lf.zsh: make completions complete both lf and lfcd #1564

Merged
merged 3 commits into from
Jan 7, 2024

Conversation

postsolar
Copy link
Contributor

Added a short comment on how to make lfcd complete CLI options and filepaths just as lf itself in ZSH.

Initially I had in mind splitting lfcd.sh into a new ZSH-specific file which would define shell completions for lfcd but then I realized it might be more simple to just leave a note on how a user could do it themselves. Let me know if the initial idea is preferred.

Copy link
Collaborator

@joelim-work joelim-work left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the PR.

I think it's actually fine to just add the lfcd completion in lf.zsh where the completion for lf is. This is how it's done for lf.bash:

lf/etc/lf.bash

Line 34 in f8399eb

complete -o filenames -F _lf lf lfcd

@joelim-work suggested a better idea: to make `lf.zsh` complete both `lf` and `lfcd`

This reverts commit c28393d.
@postsolar
Copy link
Contributor Author

I think it's actually fine to just add the lfcd completion in lf.zsh where the completion for lf is. This is how it's done for lf.bash:

This is an awesome idea, thank you for the tip. Could you please check if this change works for you? It does for me, but to be honest I'm not that well-versed with ZSH's completions system.

@postsolar postsolar changed the title Leave a note on how to add shell completions for lfcd in ZSH lf.zsh: make completions complete both lf and lfcd Jan 3, 2024
@joelim-work
Copy link
Collaborator

This is an awesome idea, thank you for the tip. Could you please check if this change works for you? It does for me, but to be honest I'm not that well-versed with ZSH's completions system.

@postsolar Thanks, I have tried it and it works for me. I have given my approval.

@joelim-work
Copy link
Collaborator

The following is unrelated, but I'm not sure if the _arguments call at the bottom needs to include -s. According to the documentation, -s is used for enabling option stacking for single-letter options:

-s

Enable option stacking for single-letter options, whereby multiple single-letter options may be combined into a single word. For example, the two options ‘-x’ and ‘-y’ may be combined into a single word ‘-xy’. By default, every word corresponds to a single option name (‘-xy’ is a single option named ‘xy’).

Options beginning with a single hyphen or plus sign are eligible for stacking; words beginning with two hyphens are not.

However lf doesn't have single-letter options. Maybe it's a typo and it's supposed to be -S (which does look useful):

-S

Do not complete options after a ‘--’ appearing on the line, and ignore the ‘--’. For example, with -S, in the line

foobar -x -- -y

the ‘-x’ is considered an option, the ‘-y’ is considered an argument, and the ‘--’ is considered to be neither.


You can try it out if you want, but if you don't want to or don't have time, I'll look into it later.

@joelim-work
Copy link
Collaborator

Actually I think it's fine to merge this as this is just about adding completion for lfcd. Anything else can be left for a separate PR.

@joelim-work joelim-work merged commit 27c71f8 into gokcehan:master Jan 7, 2024
4 checks passed
@gokcehan gokcehan mentioned this pull request Mar 31, 2024
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

Successfully merging this pull request may close these issues.

2 participants