Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

zsh-like menu for completions #291

Closed
ridiculousfish opened this Issue · 38 comments
@ridiculousfish

This issue tracks a zsh-like menu for completions, as discussed in #84

Note that in typical zsh fashion, the menu system requires some magic to enable, listed at http://www.refining-linux.org/archives/40/ZSH-Gem-5-Menu-selection/

@lledey

Great feature !

Maybe it could support backtab key (shift+tab) to return back in the list.
It would be useful if you have a very long list of matching completions and you just passed the command you wanted.

@ridiculousfish

This issue tracks proposed improvements to the pager UI. The pager is what prints the list of options when you hit tab.

Here's my thinking on what the goals ought to be:

  • Inline and interactive. It should not stay onscreen after you're done interacting with it, but it should also not have an entirely separate UI. zsh's listing of the completions below the prompt is very slick, and a good model.

  • No jarring transitions. The worst experience in the existing pager is when you tab complete and fish_pager takes over your screen with a huge list. Tab completion should never fill your screen without warning.

  • Non-modal, as far as possible. Much like history search, we should try to avoid sticking the user in a weird mode that requires special input to escape. Cautionary examples include 'reverse-history-search' and "Display all 200 possibilities? (y/n)"

  • Progressively filterable. If you have a big list of completions, it would be nice if you could filter / search it effectively, to winnow down the options you want.

My thinking on the UI is "progressive disclosure." Tab shows you a short list of completions, with an affordance for listing the rest. Because the initial list is short, it initially requires only a handful of lines.

I've committed work towards a new pager in df60c00 . It can be enabled by setting the 'fish_new_pager' variable to 1. Feedback very much welcome.

@terlar

Awesome work, looks exciting. The first spontaneous feeling is that it is kind of weird that you can use all arrow keys except one (down). Which kind of makes sense, maybe. But it feels like you move down with tab and arround with all the other keys so you have to user fingers in different places. On the other hand you cannot only use the tab since shift-tab does nothing.

I suggest that shift-tab should move in the oposite direction just like up arrow key does. That would feel more natural for me. Then you can use tab/shift-tab to navigate vertically and the arrow keys (left/right) to navigate horizontally.

Another option would be to allow the down arrow key, but maybe that will hinder some other feature.

@ridiculousfish

Hmm, the down arrow key is supposed to work! Looks like it's a bug that it doesn't.

@ridiculousfish

Heh, this appears to be due to a difference in wc between OS X and Linux.

down-or-search has this code:

set lineno (commandline -L)
set line_count (commandline|wc -l)
switch $lineno
    case $line_count
    commandline -f history-search-forward

    case '*'
    commandline -f down-line
end

On OS X, the wc -l invocation produces a leading tab. This causes it to fail to match the case $line_count line. How funny.

@ridiculousfish

Ok, the wc issue should be fixed as 2139334 , and down arrow should be made to work via 6d13b8b . Thanks for reporting that bug.

@terlar

Ah, didn't realize it was a bug, but makes sense. Thank you, works very well now. Will keep testing.

It would still be nice to have shift-tab to go backwards though, is that possible or does it have some technical limitation?

Also is there some way to set the color?

It seems it is using the variable fish_color_search_match, but when I do set fish_color_search_match white --bold --background=purple it ignores the text color. I guess it is related to the color being set for the highlighted part of the completion and then reset back explicitly to normal.

@ridiculousfish

We can definitely support shift-tab going backwards.

It should use the existing "fish_pager_color" colors, which are:

  • fish_pager_color_prefix
  • fish_pager_color_completion
  • fish_pager_color_description
  • fish_pager_color_progress
  • fish_pager_color_secondary

However the existing pager misinterprets at least fish_pager_color_progress (it sets the foreground color as the background), so things might look different.

@terlar

Just want to say I really enjoy the latest changes, the search felt very natural, very discoverable. Great work!

The only issue I have experienced but haven't really pinpointed is that sometimes when I start a new terminal it displays the search: ___________. Although I can still enter into the prompt as usual, and as soon as I enter a character it will disappear.

@terlar

Actually I can manage to freeze the search input by entering stuff, erasing it and using arrows up and down frenetically. First it seemed random, but found a way to achive this every time...

Create following directory structure:

mkdir basedir
cd basedir
mkdir Code
mkdir Documents
mkdir Downloads
mkdir Dropbox
mkdir Music
touch Notes
mkdir Pictures
touch terminfo
mkdir Videos
mkdir Volumes

Then stand inside this dir, and do following actions:

ls <tab>
<down><down>
fs
<backspace>

This operation causes freezing for me every time.

@ridiculousfish

Nice finds! The mysterious search field is probably due to a bool that I failed to initialize.

@ridiculousfish

Mystery search field should be fixed as bfc7818

@ridiculousfish

Freezing should be fixed as 2253c57

@maxfl

Maybe I'm missing it, but is there a way to open all the completions without searching and moving cursor to the bottom? I often need it when I want to use the competions list instead of manual pages to read the option descriptions.

@ridiculousfish

How about double-tapping tab to reveal everything?

@ridiculousfish

Double tapping idea is implemented as 8eaabac to see how it feels

@maxfl

I like the double-tapping idea. It's intuitive and doesn't require additional keys. Works nice.

@ridiculousfish

de2eea0 turns this on by default.

@bentolor

Kudos for this great feature. I discovered it by accident on checking the logs. And i love it!

I have one small issue: The feature seems to behave different on my various systems. While it works as expected on most systems (precise, old-stable):
fish-working

On on specific system (saucy) i cannot select / navigate entries with my arrow keys nor is the current selected proposal higlighted:
fish2

Same system. The red one is just a telnet session to home.

Any idea what causes this different behaviour?

@bentolor

I reapplied a different color theme in fish_config. It seems my issue is the missing background colouring there?

@ridiculousfish

@bschmid What value do you have set for $fish_color_search_match ?

@bentolor

@ridiculousfish In the working case --background=purple in the non-working case just purple. I never toyed with those vars directly. (Re-)applying themes via fish_config did not help/change them either.

Finally I stumbled upon vared which allowed to me change the value interactively. Thanks for the pointer!

@nasedo

How about making typing '/' synonymous with pressing enter to select a directory candidate? I miss that from zsh. It's easy to type and feels natural.

@zanchey zanchey modified the milestone: next-minor, fish-future
@zanchey
Collaborator

This is on by default now - ok to close?

@xfix
Collaborator

I guess.

@xfix xfix closed this
@gilvaju

How to use tab list completions with arrows keys?

@ridiculousfish

When the pager list is shown, you can either press the Down arrow to start navigating it, or press tab again. When an item is highlighted the arrow keys let you navigate. Does that answer your question?

@gilvaju

In my terminal that does not happen. When I press tab, the list of suggestions appears but prompt ever appears again.
screen shot 2015-05-22 at 21 19 40

@ridiculousfish

This feature is in 2.2, which isn't released yet. You can install the beta from http://fishshell.com/beta/.

@gilvaju

Ah understood. How I would install the beta version via homebrew on osx? I thank the attention.

@oschrenk

Not sure how to install a specific version but you can install directly from latest source if you like to live on the edge

brew install fish --HEAD
@gilvaju

Perfect, worked !!!!!! Thank you !!!

@jordelver

This feature is really awesome. Thank you :+1:

@pickfire

The feature is here now. Should this issue be closed?

@faho
Collaborator

The issue has been closed for almost a year now.

@pickfire

Sorry about that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.