Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PSReadLine/PlatformWindows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ internal static bool IsUsingRasterFont()
var handle = _outputHandle.Value.DangerousGetHandle();
var fontInfo = new CONSOLE_FONT_INFO_EX { cbSize = Marshal.SizeOf(typeof(CONSOLE_FONT_INFO_EX)) };
bool result = GetCurrentConsoleFontEx(handle, false, ref fontInfo);
// From https://docs.microsoft.com/en-us/windows/desktop/api/wingdi/ns-wingdi-tagtextmetrica
// From https://docs.microsoft.com/windows/win32/api/wingdi/ns-wingdi-textmetrica
// tmPitchAndFamily - A monospace bitmap font has all of these low-order bits clear;
return result && (fontInfo.FontFamily & FontFamily.LOWORDER_BITS) == 0;
}
Expand Down
26 changes: 13 additions & 13 deletions PSReadLine/SamplePSReadLineProfile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Set-PSReadLineKeyHandler -Key F7 `

# This is an example of a macro that you might use to execute a command.
# This will add the command to history.
Set-PSReadLineKeyHandler -Key Ctrl+B `
Set-PSReadLineKeyHandler -Key Ctrl+b `
-BriefDescription BuildCurrentDirectory `
-LongDescription "Build the current directory" `
-ScriptBlock {
Expand All @@ -90,27 +90,27 @@ Set-PSReadLineKeyHandler -Key Ctrl+B `

# In Emacs mode - Tab acts like in bash, but the Windows style completion
# is still useful sometimes, so bind some keys so we can do both
Set-PSReadLineKeyHandler -Key Ctrl+Q -Function TabCompleteNext
Set-PSReadLineKeyHandler -Key Ctrl+Shift+Q -Function TabCompletePrevious
Set-PSReadLineKeyHandler -Key Ctrl+q -Function TabCompleteNext
Set-PSReadLineKeyHandler -Key Ctrl+Q -Function TabCompletePrevious

# Clipboard interaction is bound by default in Windows mode, but not Emacs mode.
Set-PSReadLineKeyHandler -Key Shift+Ctrl+C -Function Copy
Set-PSReadLineKeyHandler -Key Ctrl+V -Function Paste
Set-PSReadLineKeyHandler -Key Ctrl+C -Function Copy
Set-PSReadLineKeyHandler -Key Ctrl+v -Function Paste

# CaptureScreen is good for blog posts or email showing a transaction
# of what you did when asking for help or demonstrating a technique.
Set-PSReadLineKeyHandler -Chord 'Ctrl+D,Ctrl+C' -Function CaptureScreen
Set-PSReadLineKeyHandler -Chord 'Ctrl+d,Ctrl+c' -Function CaptureScreen

# The built-in word movement uses character delimiters, but token based word
# movement is also very useful - these are the bindings you'd use if you
# prefer the token based movements bound to the normal emacs word movement
# key bindings.
Set-PSReadLineKeyHandler -Key Alt+D -Function ShellKillWord
Set-PSReadLineKeyHandler -Key Alt+d -Function ShellKillWord
Set-PSReadLineKeyHandler -Key Alt+Backspace -Function ShellBackwardKillWord
Set-PSReadLineKeyHandler -Key Alt+B -Function ShellBackwardWord
Set-PSReadLineKeyHandler -Key Alt+F -Function ShellForwardWord
Set-PSReadLineKeyHandler -Key Shift+Alt+B -Function SelectShellBackwardWord
Set-PSReadLineKeyHandler -Key Shift+Alt+F -Function SelectShellForwardWord
Set-PSReadLineKeyHandler -Key Alt+b -Function ShellBackwardWord
Set-PSReadLineKeyHandler -Key Alt+f -Function ShellForwardWord
Set-PSReadLineKeyHandler -Key Alt+B -Function SelectShellBackwardWord
Set-PSReadLineKeyHandler -Key Alt+F -Function SelectShellForwardWord

#region Smart Insert/Delete

Expand Down Expand Up @@ -310,7 +310,7 @@ Set-PSReadLineKeyHandler -Key Alt+w `
}

# Insert text from the clipboard as a here string
Set-PSReadLineKeyHandler -Key Ctrl+Shift+v `
Set-PSReadLineKeyHandler -Key Ctrl+V `
-BriefDescription PasteAsHereString `
-LongDescription "Paste the clipboard text as a here string" `
-ScriptBlock {
Expand Down Expand Up @@ -509,7 +509,7 @@ Set-PSReadLineKeyHandler -Key F1 `
#
$global:PSReadLineMarks = @{}

Set-PSReadLineKeyHandler -Key Ctrl+Shift+j `
Set-PSReadLineKeyHandler -Key Ctrl+J `
-BriefDescription MarkDirectory `
-LongDescription "Mark the current directory" `
-ScriptBlock {
Expand Down
4 changes: 2 additions & 2 deletions docs/Set-PSReadLineKeyHandler.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ This command binds the up arrow key to the function HistorySearchBackward which
### -------------- Example 2 --------------

```
PS C:\> Set-PSReadLineKeyHandler -Chord Shift+Ctrl+B -ScriptBlock {
PS C:\> Set-PSReadLineKeyHandler -Chord Ctrl+B -ScriptBlock {
>> [Microsoft.PowerShell.PSConsoleReadLine]::RevertLine()
>> [Microsoft.PowerShell.PSConsoleReadLine]::Insert('msbuild')
>> [Microsoft.PowerShell.PSConsoleReadLine]::AcceptLine()
}
```

This example binds the key Ctrl+Shift+B to a script block that clears the line, inserts build, then accepts the line.
This example binds the key Ctrl+Shift+b to a script block that clears the line, inserts build, then accepts the line.
This example shows how a single key can be used to execute a command.

## PARAMETERS
Expand Down