You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Clarify how to use the PowerShell completions #695
@dougbu I tried running gh completion --shell powershell |Out-String |Invoke-Expression in my PowerShell, which produced no output. Subsequently typing gh followed by space and pressing TAB triggers file autocompletion, not command autocompletion, sadly. Does this need to be placed in $PROFILE? I was under the impression that this would (temporarily) work in a shell in which the command was ran.
Reacted by Brandon H, Thomas Levesque and dzmitry-lahoda
@JanPokorny the completions themselves are seemingly incomplete. If I type gh pr then hit tab, I get completions for the rest of the command e.g. checkout. But, I don't get completions for anything but files if I just type gh .
W.r.t. your profile, I found the command didn't work because profiles aren't sourced. Needed the following in my profile:
I can confirm that in git bash, gh <tab>does complete.
Well that would not be coming from the Powershell completion, which is the topic of this issue, since you are explicitely using BASH.
I am able to get a second level of tab expansion (as they're called in Powershell, as opposed to tab completion in bash), but not a first level. For example (note: I am not a PS expert), creating the tab completion file:
leads me to have this work: > gh repo <tab> -- resulting in cycling through clone, create, credits, etc. But just > gh <tab> results in the shell cycling through my directories instead of the top level items.
I can't get any of the suggested solutions to work. I tried in PowerShell Core and Windows Powershell, in all cases I only have the usual file completion, no command completion. It would be nice to have an answer from the team...
As of 6/12/2021, with version 1.11.0, command and subcommand autocompletion are present.
I used @bc3tech 's command in my PowerShell $PROFILE, and everything seems to be working as expected. I get command autocompletion, then file autocompletion when typing after a subcommand.
Activity
dougbu commentedon Apr 4, 2020
I got the following to work:
or
JanPokorny commentedon Apr 17, 2020
@dougbu I tried running
gh completion --shell powershell |Out-String |Invoke-Expressionin my PowerShell, which produced no output. Subsequently typingghfollowed by space and pressing TAB triggers file autocompletion, not command autocompletion, sadly. Does this need to be placed in $PROFILE? I was under the impression that this would (temporarily) work in a shell in which the command was ran.dougbu commentedon Apr 17, 2020
@JanPokorny the completions themselves are seemingly incomplete. If I type
gh prthen hit tab, I get completions for the rest of the command e.g.checkout. But, I don't get completions for anything but files if I just typegh.W.r.t. your profile, I found the command didn't work because profiles aren't sourced. Needed the following in my profile:
I then execute
Complete-ghat the PowerShell prompt. It's a bit clunky and there's probably a better way to do this.bc3tech commentedon Apr 24, 2020
in my
$profilefile I added:and I get the expected result in a new powershell window. Agreed, though, I expected
gh <tab>to give me some options and it does not.dougbu commentedon Apr 24, 2020
Ah, great. Thanks @bc3tech❕ (The lack of completion after
ghlikely confused me when I set this up.)musm commentedon Jul 31, 2020
Gotta agree, found it very odd
gh <tab>doesn't have any completionsbinyamin commentedon Sep 18, 2020
I can confirm that in git bash,
gh <tab>does complete.jasonsyoung commentedon Oct 7, 2020
Well that would not be coming from the Powershell completion, which is the topic of this issue, since you are explicitely using BASH.
I am able to get a second level of tab expansion (as they're called in Powershell, as opposed to tab completion in bash), but not a first level. For example (note: I am not a PS expert), creating the tab completion file:
then sourcing it in my
$Profileto avoid the performance hit of recreating it on each launch (as others have done above):leads me to have this work:
> gh repo <tab>-- resulting in cycling through clone, create, credits, etc. But just> gh <tab>results in the shell cycling through my directories instead of the top level items.Any suggestions?
peschkaj commentedon Oct 7, 2020
@jasonsyoung Take a look in #1775 for a current workaround
thomaslevesque commentedon Oct 8, 2020
I can't get any of the suggested solutions to work. I tried in PowerShell Core and Windows Powershell, in all cases I only have the usual file completion, no command completion. It would be nice to have an answer from the team...
LRitzdorf commentedon Jun 12, 2021
As of 6/12/2021, with version 1.11.0, command and subcommand autocompletion are present.
I used @bc3tech 's command in my PowerShell $PROFILE, and everything seems to be working as expected. I get command autocompletion, then file autocompletion when typing after a subcommand.