Skip to content

Commit

Permalink
✨ feat: powershell completion for pyenv-win-venv
Browse files Browse the repository at this point in the history
  • Loading branch information
jacquindev committed Dec 8, 2024
1 parent cd823a8 commit 393cf1a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions dotposh/Config/posh-completions/pyenv-win-venv.ps1
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

0 comments on commit 393cf1a

Please sign in to comment.