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

ITerm2-like terminal autocomplete #6632

Open
isotes opened this issue Jun 22, 2020 · 8 comments
Open

ITerm2-like terminal autocomplete #6632

isotes opened this issue Jun 22, 2020 · 8 comments
Labels
Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Milestone

Comments

@isotes
Copy link

isotes commented Jun 22, 2020

Description of the new feature/enhancement

Provide autocomplete by the terminal (not the shell) based on previous output (comparable to the iTerm2 'Autocomplete' feature described here).

inShell

This feature does not require any knowledge about the current command but works just by inspecting the existing output as shown by the terminal. It uses the word currently being typed (based on the output and the cursor position) to provide autocompletion proposals. Therefore, it is independent of the shell and works also for other console applications that allow input, e.g., editors.

inNano

A request for this feature has been mentioned here but I don't think it has been recognised as a different feature from the issue it was mentioned in.

Proposed technical implementation details

A possible approach could be based on a set of characters that separate words. First, identify the currently typed word by going backward from the cursor to the first non-word character. Second, perform a backwards search for words with the same prefix (and stop after a certain number of proposals or amount of text searched to ensure quick and helpful feedback).

Note that in the iTerm2 implementation 'word' encompasses a whole path, i.e., both / and \ are treated as a word character, which I found very helpful.

[edited to highlight treatment of paths]

@isotes isotes added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Jun 22, 2020
@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Jun 22, 2020
@zadjii-msft
Copy link
Member

Alright yea I'll acknowledge that this is a independent request from #3121. The concept that this is implemented independently from the shell excites me - that'll make this infinitely easier to support.

This might fit in well as a possible extension, so I'll tag it into that thread.

@zadjii-msft zadjii-msft added Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. labels Jun 22, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Jun 22, 2020
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Jun 22, 2020
@WSLUser
Copy link
Contributor

WSLUser commented Jun 22, 2020

We'll need to be sure it doesn't cause issues with bash completion, PSReadline, oh-my-zsh/fish, etc. I'm used to just normal bash completion and PSReadline so not sure how Iterm2 does it exactly if it sees that a shell auto-complete extension is being used.

@zadjii-msft
Copy link
Member

I mean, it seems like the Terminal's auto-complete that's provided by scanning the buffer like this would be totally different than the shell's autocomplete. If the Terminal's auto complete is bound to the same keystroke as the shell's autocomplete, the the Terminal binding would take precedence (as it does with every other keybinding currently). I certainly wouldn't want this as an "always on" functionality, because yea, that would confuse things.

As far as implementation details goes, it doesn't seem to hard to just send the suggestion as a string of input to the shell, just the same as if the user had typed it. I don't think the shell would need to know at all that the Terminal would support such a feature.

@WSLUser
Copy link
Contributor

WSLUser commented Jun 22, 2020

So we'll just need to throw this behind a setting which could be toggled on/off with a keybinding.

@isotes
Copy link
Author

isotes commented Jun 22, 2020

Everything that @zadjii-msft said.

iTerm2 uses CMD-; as the (default) keybinding. This functionality is mostly orthogonal to shell completion - both with respect to the keybinding and the kind of completions it can provide.

@DHowett DHowett removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Jun 26, 2020
@DHowett
Copy link
Member

DHowett commented Jun 26, 2020

This is pretty cool. Thanks for requesting!

@oising
Copy link
Collaborator

oising commented Jun 26, 2020

Windows kinda does this to an extent with the old conhost's F9 history -- this list comes from conhost, not the shell. So it's not without some kind of precedent already, right? One question though: How will the terminal differentiate command input from password/sensitive input? Do you really want that stuff in history? (again, F9 did it, but that doesn't mean it's right...)

Edit: never mind, I should think more before typing. I guess iterm2 only captures output/echo, not input. As long as you use interactive input for passwords, and its masked, it's safe.

@pcgeek86
Copy link

Still hoping to see this added to Windows terminal. It's annoying to have to copy-paste stuff with the mouse, which could easily be completed by the Terminal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Extensibility A feature that would ideally be fulfilled by us having an extension model. Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

6 participants