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

[FR] automatically insert common prefix #89

Closed
romkatv opened this issue May 18, 2020 · 2 comments
Closed

[FR] automatically insert common prefix #89

romkatv opened this issue May 18, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@romkatv
Copy link
Contributor

romkatv commented May 18, 2020

Setup:

mkdir -p /tmp/foo/{bar1,bar2}

Currently, when I type ls /tmp/foo/<TAB>, I get this:

❯ ls /tmp/foo/
> bar
  2/2
> bar1/
  bar2/

And if I press Ctrl-C, I get this:

❯ ls /tmp/foo/

What I would like is for bar to be inserted automatically when I type ls /tmp/foo/<TAB>. There are two ways it could work, and both would work for me.

  1. Just insert bar and not trigger fzf. In other words, fzf triggers only where there is no common prefix (empty query).
  2. Insert bar and then immediately trigger fzf.
❯ ls /tmp/foo/bar
> bar
  2/2
> bar1/
  bar2/

Note bar in the command line. If I now hit Ctrl-C, bar should be retained.

❯ ls /tmp/foo/bar

Is (1) and/or (2) possible? I think I've seen a similar question with your answer but I cannot find it.

The reason I want this is that I often want to insert long file prefixes and then manually add *. In the example above my goal was perhaps to execute ls /tmp/foo/bar*

@romkatv romkatv added the enhancement New feature or request label May 18, 2020
@Aloxaf
Copy link
Owner

Aloxaf commented May 18, 2020

I think I've seen a similar question with your answer but I cannot find it.

Maybe #8?

Is (1) and/or (2) possible?

Yes, it's easy to finish basic support -- just insert $query if it exists. But when it comes to a complex scene, it will be hard to deal with prefix/suffix. eg. print ${ZSH\t will turn into print ${ZSH_}, in which } is not expected.

It may take some time to come up with a workaround.

@romkatv
Copy link
Contributor Author

romkatv commented May 23, 2020

I think I've seen a similar question with your answer but I cannot find it.

Maybe #8?

Thanks! Yes, that was the issue I was looking for. The offered solution doesn't work very well. I'll try to come up with something better. Will let you know if I succeed.

@romkatv romkatv closed this as completed May 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants