-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: powershell completion for
pyenv-win-venv
- Loading branch information
1 parent
cd823a8
commit 393cf1a
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
### pyenv-win-venv powershell completion | ||
|
||
$pyenvVenvCommand = (Get-Command 'pyenv-win-venv' -ErrorAction SilentlyContinue) | ||
|
||
if ($pyenvVenvCommand) { | ||
if ($pyenvVenvCommand.ScriptContents | Select-String -Pattern 'completion') { | ||
# Run pyenv-venv completion script asynchronously | ||
Register-EngineEvent -SourceIdentifier PowerShell.OnIdle -MaxTriggerCount 1 -Action { | ||
&"pyenv-win-venv.ps1" completion | Out-String | Invoke-Expression | ||
} | Out-Null | ||
|
||
} else { | ||
# If there is no internet connection, then silently exit | ||
if ((Test-Connection -ComputerName www.google.com -Count 1 -Quiet -ErrorAction Stop) -eq $False) { return } | ||
|
||
# Completion script from pyenv-win-venv fork repository: https://github.com/jacquindev/pyenv-win-venv | ||
Invoke-RestMethod -Uri "https://raw.githubusercontent.com/jacquindev/pyenv-win-venv/refs/heads/main/completions/pyenv-win-venv.ps1" | | ||
Invoke-Expression | ||
} | ||
} | ||
|
||
Remove-Variable pyenvVenvCommand |