mirror of
https://github.com/swaywm/sway.git
synced 2026-04-20 06:47:03 -04:00
Add sway, swaymsg and swaynag completions for pwsh
This commit is contained in:
parent
6059c744f8
commit
bb7b365d37
3 changed files with 129 additions and 0 deletions
26
completions/pwsh/sway.ps1
Normal file
26
completions/pwsh/sway.ps1
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
# Based on the following documentation and tons of trial and error:
|
||||
# https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/register-argumentcompleter?view=powershell-7.1
|
||||
|
||||
Register-ArgumentCompleter -Native -CommandName sway -ScriptBlock {
|
||||
param($wordToComplete, $commandAst, $cursorPosition)
|
||||
|
||||
$completions = @(
|
||||
'--help',
|
||||
'--config',
|
||||
'--validate',
|
||||
'--debug',
|
||||
'--version',
|
||||
'--verbose',
|
||||
'--get-socketpath'
|
||||
)
|
||||
|
||||
if ($commandAst.CommandElements.Count -ge 2) {
|
||||
if ($commandAst.CommandElements[1].ToString() -in @( '-c', '--config' )) {
|
||||
$completions = Get-ChildItem | Select-Object -ExpandProperty Name
|
||||
}
|
||||
}
|
||||
|
||||
$completions | Where-Object { $_.StartsWith($wordToComplete) } | ForEach-Object {
|
||||
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue