Not ever having done this, I expect you'd start by using "Set-PSReadlineKeyHandler" and including in its scriptblock the completions you want to offer for a given keystroke or chord. Include the Set-PSReadlineKeyHandler cmdlet(s) in your PowerShell profile (sorry, I don't know where that is located in *nix) -- if it was Windows it'd be here: C:\Users[User]\Documents\WindowsPowerShell\profile.ps1.
Powershell Linux: How to create simple argument TAB Completion for native Linux command
Hi,
I just started learning Powershell on Linux (Debian).
What I try to do is the following.
I have a Bash script called "zst" in /usr/bin/
with TAB completions for it to complete arguments like:
zst <TAB>
which gives me a list of possible arguments.
The TAB completer is a standard Bash script to create the strings ( just a curl call to some REST API).
If I use Powershell, of course I can run "zst" but without the TAB completions.
How can I achieve this?
I read something about ArgumentCompleters
https://adamtheautomator.com/powershell-parameters-argumentcompleter/
Can someone point me to the right direction?
Thanks in advance.
Windows for business Windows Server User experience PowerShell
2 answers
Sort by: Most helpful
-
-
swick 1 Reputation point
2020-09-30T11:37:01.957+00:00 Thanks for the hint. I will try it with Set-PSReadlineKeyHandler.
In the meantime I succeeded with the following solution
Register-ArgumentCompleter -Native -CommandName zst -ScriptBlock { param($wordToComplete) (curl -s https://server/resources/txt | grep ^$wordToComplete) }