-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or requesthacktoberfestHacktoberfest issues to addressHacktoberfest issues to address
Milestone
Description
Goal for this would be to enable storage of PSReadline Options, KeyHandlers, etc in your PSProfile configuration. These would ideally be ran as the appropriate command during PSProfile load, eliminating the need for a separate PSReadline settings script.
Initial approach: The commands below would be turned into the following hashtable property on $PSProfile.Settings:
Set-PSReadLineOption -HistorySearchCursorMovesToEnd
Set-PSReadLineKeyHandler -Chord Tab -Function MenuComplete
Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
Set-PSReadLineKeyHandler -Key Alt+j -BriefDescription ShowDirectoryMarks -LongDescription "Show the currently marked directories" -ScriptBlock {
param($key, $arg)
$global:PSReadLineMarks.GetEnumerator() | ForEach-Object {
[PSCustomObject]@{Key = $_.Key; Dir = $_.Value }
} | Format-Table -AutoSize | Out-Host
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
}$PSProfile.Settings.PSReadline = @{
Options = @{
HistorySearchCursorMovesToEnd = $true
}
KeyHandlers = @(
@{
Chord = 'Tab'
Function = 'MenuComplete'
}
@{
Key = 'UpArrow'
Function = 'HistorySearchBackward'
}
@{
Key = 'DownArrow'
Function = 'HistorySearchForward'
}
@{
Key = 'Alt+j'
BriefDescription = 'ShowDirectoryMarks'
LongDescription = 'Show the currently marked directories'
ScriptBlock = 'param($key, $arg)
$global:PSReadLineMarks.GetEnumerator() | ForEach-Object {
[PSCustomObject]@{Key = $_.Key; Dir = $_.Value }
} | Format-Table -AutoSize | Out-Host
[Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()'
}
)
}During PSProfile import, the hashtable in $PSProfile.Settings.PSReadline would be parsed, converted to the original commands, then executed so they're available in the current session as they would normally be from an ExternalScript.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requesthacktoberfestHacktoberfest issues to addressHacktoberfest issues to address