Last active
October 18, 2018 03:20
-
-
Save GhostofGoes/03e40f5b642e0e1b35206027c9cd9c01 to your computer and use it in GitHub Desktop.
PowerShell completion for Pipenv. Edit: "notepad $profile.CurrentUserAllHosts"
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
function TabExpansion($line, $lastWord) { | |
$lastBlock = [regex]::Split($line, '[|;]')[-1].TrimStart() | |
$aliases = @("pipenv") + @(Get-Alias | where { $_.Definition -eq "pipenv" } | select -Exp Name) | |
$aliasPattern = "($($aliases -join '|'))" | |
if($lastBlock -match "^$aliasPattern ") { | |
$Env:_PIPENV_COMPLETE = "complete-powershell" | |
$Env:COMMANDLINE = "$lastBlock" | |
(pipenv) | ? {$_.trim() -ne "" } | |
Remove-Item Env:_PIPENV_COMPLETE | |
Remove-Item Env:COMMANDLINE | |
} | |
elseif (Test-Path Function:\pipenvTabExpansionBackup) { | |
# Fall back on existing tab expansion | |
pipenvTabExpansionBackup $line $lastWord | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment