-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Start fzf from current row #405
Comments
Amazing, I never thought this would be possible. This is definitely going to be useful when not on tmux. With a few improvements we can even consider adding it to |
I got the desire of this sort of layout having played with selecta. It has some rendering issues which seem to be addressed in a rust clone heatseaker which I've stumbled across today. Not sure if you've thought about this kind of interface for fzf? Just an off-hand comment, I appreciate it's not very useful without patches. |
Oh yeah, I'm aware of those projects. Unlike fzf, they use low-level ANSI codes to control the screen instead of depending on ncurses. The approach has the benefit of not having to use fullscreen, which I think is really nice. However, it seems much less stable than rock-solid ncurses, and cannot reliably support various key bindings and mouse like fzf does (yes I do use mouse on fzf sometimes!). And since tmux integration, I'm more or less content with the way fzf works. I suggest a few changes to the script:
# Start fzf from the current row
opts=
if [ "$row" -lt "$halfway" ]; then
start_row=$(expr $row - 1)
opts="--reverse --margin ${start_row},0,0"
else
start_row=$(expr $lines - $row)
[ $start_row -eq 1 ] && start_row=0
opts="--no-reverse --margin 0,0,${start_row}"
fi
fzf "$@" $opts And I like the script so far, it looks pretty clever, though I'm almost always on tmux so I'm not so sure if I'm going to use it often. Do you think it makes sense to include the script in the official repo? |
Thanks for the insight! I agree with all your points.
Originally I was intending to just put this on the wiki, I think this should be fairly portable so I guess it's not harmful to have it in the main repo. If it does go into the repo maybe the |
@George-B What's your termial? I have tested it in By the way: You can calculate in POSIX shell without subshells using arithmetic expansion like |
@d630 Guilty confession I'm in PuTTY most of the time these days, thanks for the arithmetic tip. I'll have to spin up a VM and do some testing with |
@George-B How about sending me a pull request? We can continue the discussion there. By the way, I have absolutely no idea how we should call the script ;) I think we can even consider using it in the default key bindings and fuzzy completion when not on tmux. |
AFAIK ncurses still clears the whole screen even when starting using a margin right? |
PS: I ask because I was preparing a pull-request which added an "auto-margin" option which retrieved the current cursor position and then computed the margin accordingly. However, after all the ioctls where done I realized that margin doesn't really prevent fzf from clearing the entire screen. |
@acornejo Yeah, that is basically how ncurses works. |
Tks @junegunn, just closed the PR. If clearing the screen is unavoidable I don't see how starting from the current row is a desirable feature (if someone sees value on it, let me know since I had the code to add this to the fzf binary instead of doing it through shell scripts). |
Woah totally forgot about this! I'm actually not using fzf much these days, @junegunn should this be closed? |
Rather than just dropping this on the wiki I just wanted to post this first as I'm sure it's pretty ugly.
This works out how may rows the terminal has and which row you are on. It then starts fzf on the current row and displays the possible completion options above or below depending on which has the most space. I find this makes the invocation of fzf less jarring in some ways.
Any and all feedback appreciated!
The text was updated successfully, but these errors were encountered: