Closed Konfekt closed 11 months ago
Run following code in powerwshell to check versions and deps:
cd $env:ARGC_COMPLETIONS_ROOT
argc version
The output text should look like the following:
argc 1.12.1
yq (https://github.com/mikefarah/yq/) version v4.34.1
GNU Awk 5.0.0, API: 2.0 (GNU MPFR 4.2.0-p9, GNU MP 6.2.1)
sed (GNU sed) 4.9
Please let me know the results after execution so that I can analyze the problem. @Konfekt
All fine, impressive, updating from powershell 7.2.6 to 7.3.2 solved the problem
For completeness, it's the following output:
argc 1.12.1
yq (https://github.com/mikefarah/yq/) version v4.40.2
GNU Awk 4.2.1, API: 2.0
sed (GNU sed) 4.4
How about a check such as
if [ -d "$ARGC_COMPLETIONS_ROOT" ]; then
export PATH="$ARGC_COMPLETIONS_ROOT/bin:$PATH"
source <(ls -p -1 "$ARGC_COMPLETIONS_ROOT/completions" | sed -n 's/\.sh$//p' | xargs argc --argc-completions bash)
else
echo "Please install argc-completions following https://github.com/sigoden/argc-completions#getting-started"
fi
ARGC_COMPLETIONS_PATH is like PATH, it may contains multiple path. see https://github.com/sigoden/argc/blob/main/docs/environment-variables.md
Okay, I adapted
$ARGC_COMPLETIONS_ROOT
is required. Some scripts need $ARGC_COMPLETIONS_ROOT
to locate _argc_util*
functions like https://github.com/sigoden/argc-completions/blob/3d51c72134ff3a75f1cf82e76b3db947d4f15b59/completions/git.sh#L2764
Argc internally use Register-ArgumentCompleter
for completing. is the version requirement for PowerShell that high?
argc-completions can work on PS 5.1, but considering PowerShell/PowerShell#2912, you will have a better experience in PS 7+
Not sure about the lowest version making it work over here. As I tried on Linux, I only can try Pwsh versions > 5
Maybe
ARGC_COMPLETIONS_ROOT=/home/konfekt/argc-completions
if [ -d "$ARGC_COMPLETIONS_ROOT" ]; then
export ARGC_COMPLETIONS_ROOT
export ARGC_COMPLETIONS_PATH="$ARGC_COMPLETIONS_ROOT/completions"
export PATH="$ARGC_COMPLETIONS_ROOT/bin:$PATH"
source <(ls -p -1 "$ARGC_COMPLETIONS_ROOT/completions" | sed -n 's/\.sh$//p' | xargs argc --argc-completions zsh)
else
unset ARGC_COMPLETIONS_ROOT
echo "Please install argc-completions following https://github.com/sigoden/argc-completions#getting-started!"
fi
is the safest bet with the idea of using the same .zshrc
on different computers.
Powershell Version:
# Set-PSReadlineKeyHandler -Key Tab -Function MenuComplete
$ARGC_COMPLETIONS_ROOT = $env:HOME + '/argc-completions'
if (Test-Path -Path $ARGC_COMPLETIONS_ROOT) {
$env:ARGC_COMPLETIONS_ROOT = $ARGC_COMPLETIONS_ROOT
$env:ARGC_COMPLETIONS_PATH = ($env:ARGC_COMPLETIONS_ROOT + '/completions')
$env:PATH = $env:ARGC_COMPLETIONS_ROOT + '/bin' + [IO.Path]::PathSeparator + $env:PATH
argc --argc-completions powershell (
(Get-ChildItem -File ($env:ARGC_COMPLETIONS_ROOT + '/completions')) |
ForEach-Object { $_.Name -replace '\.sh$' }) | Out-String | Invoke-Expression
} else {
Remove-Item ARGC_COMPLETIONS_ROOT
Write-Host "Please install argc-completions!"
}
$ARGC_COMPLETIONS_ROOT
should be together with the argc-completions
directory.
If you delete the argc-completions
directory , you should remove the setup script from your shell.
I understand. The idea is that on some computers the directory is available, on others not.
By the way, I think people would be more comfortable if the added lines such as in https://github.com/sigoden/argc-completions/issues/15#issuecomment-1826439125 would be shown right away instead of saying that somehow the config files will be suitably adapted for argc-completions. At least mention that it will be not more than five lines or so.
Hello, thank you for this splendid tool. I wanted to test it in Pwsh 7.2.6. After running
there is an entry
in
Microsoft.PowerShell_profile.ps1
. However, only completion for built-ins likegci
works. As I suposed this would add completion to commands such asgrep
as well, I might be missing something?