-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improved powershell support, including hotkeys
- Loading branch information
Showing
7 changed files
with
135 additions
and
38 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
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
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,24 @@ | ||
$null = New-Item -Force -Path $env:APPDATA\IntelliShell\Intelli-Shell\bin -Type Directory | ||
Invoke-WebRequest -UseBasicParsing -URI "https://github.com/lasantosr/intelli-shell/releases/latest/download/intelli-shell-x86_64-pc-windows-msvc.zip" -OutFile .\intelli-shell.zip | ||
Expand-Archive -Force -Path intelli-shell.zip -DestinationPath $env:APPDATA\IntelliShell\Intelli-Shell\bin | ||
Remove-Item intelli-shell.zip | ||
$Path = [Environment]::GetEnvironmentVariable("PATH", [EnvironmentVariableTarget]::User) | ||
if ($Path -NotLike "*IntelliShell*") { | ||
$Path = $Path + [IO.Path]::PathSeparator + "$env:APPDATA\IntelliShell\Intelli-Shell\bin" | ||
[Environment]::SetEnvironmentVariable("Path", $Path, [EnvironmentVariableTarget]::User) | ||
} | ||
$ProfileContent = $null | ||
if (Test-Path -Path $Profile -PathType Leaf) { | ||
$ProfileContent = Get-Content -Raw $Profile | ||
} else { | ||
$Parent = Split-Path -parent $Profile | ||
$null = New-Item -Force -ItemType Directory -Path $Parent | ||
$null = New-Item -ItemType File -Path $Profile | ||
} | ||
if (($null -eq $ProfileContent) -Or ($ProfileContent -NotLike "*IntelliShell*")) { | ||
Add-Content $Profile "`n# IntelliShell" | ||
Add-Content $Profile "# `$env:INTELLI_SEARCH_HOTKEY = 'Ctrl+Spacebar'" | ||
Add-Content $Profile "# `$env:INTELLI_BOOKMARK_HOTKEY = 'Ctrl+b'" | ||
Add-Content $Profile "# `$env:INTELLI_LABEL_HOTKEY = 'Ctrl+l'" | ||
Add-Content $Profile ". `$env:APPDATA\IntelliShell\Intelli-Shell\bin\intelli-shell.ps1" | ||
} |
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
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,63 @@ | ||
$IntelliSearchChord = if ($null -eq $env:INTELLI_SEARCH_HOTKEY) { 'Ctrl+Spacebar' } else { $env:INTELLI_SEARCH_HOTKEY } | ||
$IntelliBookmarkChord = if ($null -eq $env:INTELLI_BOOKMARK_HOTKEY) { 'Ctrl+b' } else { $env:INTELLI_BOOKMARK_HOTKEY } | ||
$IntelliLabelChord = if ($null -eq $env:INTELLI_LABEL_HOTKEY) { 'Ctrl+l' } else { $env:INTELLI_LABEL_HOTKEY } | ||
|
||
Set-PSReadLineKeyHandler -Chord $IntelliSearchChord -BriefDescription "IntelliShell Search" -Description "Searches for a bookmarked command" -ScriptBlock { | ||
$line = $null | ||
$cursor = $null | ||
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor) | ||
|
||
$TempFile = New-TemporaryFile | ||
$line = $line -replace '"','""""""""""""' | ||
$Command = 'intelli-shell.exe --file-output=""""' + $TempFile.FullName + '"""" search """"' + $line + '""""' | ||
Start-Process powershell.exe -Wait -NoNewWindow -ArgumentList "-command ""$Command""" -RedirectStandardError "NUL" | ||
$IntelliOutput = Get-Content -Raw $TempFile | ||
Remove-Item $TempFile | ||
|
||
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() | ||
[Microsoft.PowerShell.PSConsoleReadLine]::BeginningOfLine() | ||
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() | ||
if (-Not [string]::IsNullOrWhiteSpace($IntelliOutput)) { | ||
[Microsoft.PowerShell.PSConsoleReadLine]::Insert($IntelliOutput) | ||
} | ||
} | ||
|
||
Set-PSReadLineKeyHandler -Chord $IntelliBookmarkChord -BriefDescription "IntelliShell Bookmark" -Description "Bookmarks current command" -ScriptBlock { | ||
$line = $null | ||
$cursor = $null | ||
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor) | ||
|
||
$TempFile = New-TemporaryFile | ||
$line = $line -replace '"','""""""""""""' | ||
$Command = 'intelli-shell.exe --file-output=""""' + $TempFile.FullName + '"""" save """"' + $line + '""""' | ||
Start-Process powershell.exe -Wait -NoNewWindow -ArgumentList "-command ""$Command""" -RedirectStandardError "NUL" | ||
$IntelliOutput = Get-Content -Raw $TempFile | ||
Remove-Item $TempFile | ||
|
||
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() | ||
[Microsoft.PowerShell.PSConsoleReadLine]::BeginningOfLine() | ||
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() | ||
if (-Not [string]::IsNullOrWhiteSpace($IntelliOutput)) { | ||
[Microsoft.PowerShell.PSConsoleReadLine]::Insert($IntelliOutput) | ||
} | ||
} | ||
|
||
Set-PSReadLineKeyHandler -Chord $IntelliLabelChord -BriefDescription "IntelliShell Label" -Description "Triggers label replace for current command" -ScriptBlock { | ||
$line = $null | ||
$cursor = $null | ||
[Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor) | ||
|
||
$TempFile = New-TemporaryFile | ||
$line = $line -replace '"','""""""""""""' | ||
$Command = 'intelli-shell.exe --file-output=""""' + $TempFile.FullName + '"""" label """"' + $line + '""""' | ||
Start-Process powershell.exe -Wait -NoNewWindow -ArgumentList "-command ""$Command""" -RedirectStandardError "NUL" | ||
$IntelliOutput = Get-Content -Raw $TempFile | ||
Remove-Item $TempFile | ||
|
||
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() | ||
[Microsoft.PowerShell.PSConsoleReadLine]::BeginningOfLine() | ||
[Microsoft.PowerShell.PSConsoleReadLine]::RevertLine() | ||
if (-Not [string]::IsNullOrWhiteSpace($IntelliOutput)) { | ||
[Microsoft.PowerShell.PSConsoleReadLine]::Insert($IntelliOutput) | ||
} | ||
} |
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
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