2

I use auto-complete heavily...

When I invoke the auto-completion with tab key...
Powershell also includes any files from the current folder
or in the current path in the autocomplete list

How can I configure Powershell to ignore these files
(eg. auto-complete only with Powershell commands/functions)

ZEE
  • 2,931
  • 5
  • 35
  • 47
  • I think you would need to implement your own KeyHandler event for `Tab` / `Shift+Tab`. I'm unsure how to view PSReadLine's current implementation since their module doesn't give you that much insight with `Get-PSReadLineKeyHandler`, but I'm sure the [implementation is here somewhere](https://github.com/lzybkr/PSReadLine/tree/master/PSReadLine) – Maximilian Burszley Oct 18 '18 at 13:42
  • thanks... it seems a lot of work just to activate a simple configuration that should be present as an option... ;-) – ZEE Oct 18 '18 at 16:56
  • It appears I may be wrong. [Here's an answer that should help you](https://stackoverflow.com/questions/8264655/how-to-make-powershell-tab-completion-work-like-bash/37715242#37715242). Try this: `Set-PSReadlineKeyHandler -Key Tab -Function` ALT+SPACE (to trigger intellisense) – Maximilian Burszley Oct 18 '18 at 17:03
  • thanks... I already use Tab-as-Alt+Space... that is for purpouse.. very useful.. but not what I asked... – ZEE Oct 18 '18 at 23:56
  • You misunderstand my comment. Press alt+tab for the function parameter. Tab completion is not the same as invoking intellisense – Maximilian Burszley Oct 18 '18 at 23:58
  • Thanks for your suggestion... I know what Intellisense is... I've done programming in VB and in C#... but what I'm asking is if there are any way of tell powershell yo not getting the files in the current folder... or in path... when asking for auto-completion... – ZEE Oct 22 '18 at 12:55

1 Answers1

2

There is no simple way to get the behavior you're looking for.

At best, you can define your own function named TabExpansion2 and either fully implement tab completion yourself (definitely not recommended) or filter the results returned from the default implementation of TabExpansion2.

I recall discussing this idea recently, I thought there might even be an open issue, but I didn't see it after a quick search here.

I don't know the exact history, but at one point we did implement the behavior you're wanting. It did break some tests, and I think some people preferred seeing effectively useless completions over no completions, perhaps it was reassuring that completions were still working.

At any rate, I think it's a reasonable feature request, I'd suggestion opening an issue if you can't find one.

Jason Shirk
  • 7,734
  • 2
  • 24
  • 29
  • Thanks... it seems too much work for a thing that should be present as a configuration option... I realy don't wanna use the boxing glove to kill the flea! ;-) Thanx – ZEE Oct 22 '18 at 12:57
  • 1
    An issue was opened recently, feel free to chime in here: https://github.com/PowerShell/PowerShell/issues/8092 – Jason Shirk Oct 22 '18 at 15:15