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

Tab competition: tab vs right arrow #934

Open
matys1 opened this issue Dec 5, 2022 · 5 comments
Open

Tab competition: tab vs right arrow #934

matys1 opened this issue Dec 5, 2022 · 5 comments

Comments

@matys1
Copy link

matys1 commented Dec 5, 2022

System Details

  • posh-git version/path: 1.1.0 ~\Documents\PowerShell\Modules\posh-git\1.1.0
  • PowerShell version: 7.3.0
  • git version 2.38.1.windows.1
  • OS: Microsoft Windows NT 10.0.19044.0

Issue Description

I'm confused by the behavior of pressing tab key for tab completion. Two examples:

First: I type in git st and the autocomplete suggestion is git status. I press tab and it completes it as git stash. I then have to press tab again to cycle and get git status, the command that was initially suggested and the one that I needed.

Two: I type in git co and the autocomplete suggestion is git commit -am "amended docs" based on my historic commits. I press tab as I want to repeat the same command again and it completes to git checkout.

However, in both examples, if I were to press right arrow instead of tab, it would complete the suggested command in full as suggested and as expected. What's the logic behind the tab command? How can I configure so the tab functions like the right arrow?

@mrkaarel
Copy link

mrkaarel commented Dec 9, 2022

The suggestions you are seeing as you type, are not provided by posh-git but by PowerShell PSReadLine module. These work in all directories, not only inside git repositories.

When you press tab key, you are getting posh-git autocompletion. When you press right arrow, you'll get PSReadLine autocompletion.

If this is confusing, you can turn off PSReadLine inline suggestions. Maybe sometimes in the future posh-git will have a auto-completion plugin that is compatible with PSReadLine.

@matys1
Copy link
Author

matys1 commented Dec 14, 2022

@mrkaarel Thank you very much, you've given me enough information to make the changes I needed. I ended up moving PSReadLine's AcceptSuggestion to Tab and AcceptNextSuggestionWord to RightArrow in effect overriding posh-git's tab completion completely as my preference was to use PSReadLine. Not sure if there's a proper way to disable posh-git's tab completion via ps1 profile settings though? Either way this works for me now.

@vegar
Copy link

vegar commented Apr 12, 2023

@matys1 , Be aware, though, that PSReadLine's suggestions comes from your history, not from the current context. So while it will suggest co to be commit, it will not be able to suggest what file to add based on your modified files. I'll also question how useful history based auto suggestion is for 'git commit' - how often do you reuse the same commit message?

@mohammad-mghn
Copy link

The suggestions you are seeing as you type, are not provided by posh-git but by PowerShell PSReadLine module. These work in all directories, not only inside git repositories.

When you press tab key, you are getting posh-git autocompletion. When you press right arrow, you'll get PSReadLine autocompletion.

If this is confusing, you can turn off PSReadLine inline suggestions. Maybe sometimes in the future posh-git will have a auto-completion plugin that is compatible with PSReadLine.

how can we change the inline suggestion from arrow right to tab?

@vegar
Copy link

vegar commented Jun 6, 2023

Take a look at the readme for PSReadLine:

To view the current key bindings:

Get-PSReadLineKeyHandler

To set your own custom keybindings, use the cmdlet Set-PSReadLineKeyHandler. For example, for a better history experience, try:

Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

If you combinde that with @matys1 reply a little further up, I'm sure you'll reach your goal :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants