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

Show fzy under prompt, not on top of it #12

Closed
maximbaz opened this issue Oct 25, 2018 · 3 comments
Closed

Show fzy under prompt, not on top of it #12

maximbaz opened this issue Oct 25, 2018 · 3 comments
Assignees

Comments

@maximbaz
Copy link
Contributor

It would be very useful to show fzy under prompt, so the currently typed command remains visible.

Let's say you want to open two files at once in vim. Because fzy lacks multiselect, the only available way is to trigger zsh-fzy multiple times. With #11 I sneaked in a little patch that allows to do so with just pressing Ctrl+T instead of <Space>Ctrl+T, but because you can't see the prompt you can easily forget which files you've already selected and which not.

Same applies for proc widget, if you want to kill multiple processes at once, you want to see your kill command build up, select first process, see that your kill became kill 1234 , select second process, see that your command expanded to kill 1234 5678 , etc.

I didn't find yet how fzf achieves this, do you have a hint for me maybe?

I even think this behavior should replace the current behavior, i.e. I wouldn't add a configuration option to return the current approach where fzy overlays prompt. But if you deliberately wanted this, then of course I'm happy to make it configurable.

@aperezdc aperezdc self-assigned this Oct 30, 2018
@maximbaz
Copy link
Contributor Author

Nice! 🎉

@aperezdc
Copy link
Owner

aperezdc commented Oct 30, 2018

Great suggestion! I didn't really know how to do this, but while thinking how nice this would be in order to make fzy behave like the Zsh completion menus, which also appear under the prompt, it crossed my mind that there's probably something in Zsh that can do the “print below the prompt, go back to the prompt afterwards” routine. And there is a way:

function some-widget {
    zle -M 'some string'
    # Now call fzy, do things.
    zle redisplay
}

Adding the above to a widget function will make Zle save the prompt position, print some string below the prompt, which causes the terminal cursor to go down one line, and the redisplay will go back and repaint the prompt in the saved position. Because the cursor went down one line, invoking fzy now overwrites some string instead of the prompt.

@maximbaz
Copy link
Contributor Author

Genius idea, I couldn't think how to even start approaching this, turns out it's very simple 🙂

Rebased #11 on master, so the proc widget also appears under the prompt now.

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