Giter Site home page Giter Site logo

psreadline's Introduction

appveyor-build-status

PSReadLine

This module replaces the command line editing experience of PowerShell for versions 3 and up. It provides:

  • Syntax coloring
  • Simple syntax error notification
  • A good multi-line experience (both editing and history)
  • Customizable key bindings
  • Cmd and emacs modes (neither are fully implemented yet, but both are usable)
  • Many configuration options
  • Bash style completion (optional in Cmd mode, default in Emacs mode)
  • Bash/zsh style interactive history search (CTRL-R)
  • Emacs yank/kill ring
  • PowerShell token based "word" movement and kill
  • Undo/redo
  • Automatic saving of history, including sharing history across live sessions
  • "Menu" completion (somewhat like Intellisense, select completion with arrows) via Ctrl+Space

The "out of box" experience is meant to be very familiar to PowerShell users - there should be no need to learn any new key strokes.

Some good resources about PSReadLine:

  • Keith Hill wrote a great introduction (2013) to PSReadLine.
  • Ed Wilson (Scripting Guy) wrote a series (2014-2015) on PSReadLine.
  • John Savill has a video (2021) covering installation, configuration, and tailoring PSReadLine to your liking.

Installation

There are multiple ways to install PSReadLine.

Install from PowerShellGallery (preferred)

You will need the 1.6.0 or a higher version of PowerShellGet to install the latest prerelease version of PSReadLine.

Windows PowerShell 5.1 ships an older version of PowerShellGet which doesn't support installing prerelease modules, so Windows PowerShell users need to install the latest PowerShellGet (if not yet) by running the following commands from an elevated Windows PowerShell session:

Install-Module -Name PowerShellGet -Force
Exit

After installing PowerShellGet, you can get the latest prerelease version of PSReadLine by running

Install-Module PSReadLine -AllowPrerelease -Force

If you only want to get the latest stable version, run:

Install-Module PSReadLine

[!NOTE] Prerelease versions will have newer features and bug fixes, but may also introduce new issues.

If you are using Windows PowerShell on Windows 10 or using PowerShell 6+, PSReadLine is already installed. Windows PowerShell on the latest Windows 10 has version 2.0.0-beta2 of PSReadLine. PowerShell 6+ versions have the newer prerelease versions of PSReadLine.

Install from GitHub (deprecated)

With the preview release of PowerShellGet for PowerShell V3/V4, downloads from GitHub are deprecated. We don't intend to update releases on GitHub, and may remove the release entirely from GitHub at some point.

Post Installation

If you are using Windows PowerShell V5 or V5.1 versions, or using PowerShell 6+ versions, you are good to go and can skip this section.

Otherwise, you need to edit your profile to import the module. There are two profile files commonly used and the instructions are slightly different for each. The file C:\Users\[User]\Documents\WindowsPowerShell\profile.ps1 is used for all hosts (e.g. the ISE and powershell.exe). If you already have this file, then you should add the following:

if ($host.Name -eq 'ConsoleHost')
{
    Import-Module PSReadLine
}

Alternatively, the file C:\Users\[User]\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 is for powershell.exe only. Using this file, you can simply add:

Import-Module PSReadLine

In either case, you can create the appropriate file if you don't already have one.

Upgrading

When running one of the suggested commands below, be sure to exit all instances of powershell.exe, pwsh.exe or pwsh, including those opened in VSCode terminals.

Then, to make sure PSReadLine isn't loaded:

  • if you are on Windows, run the suggested command below from cmd.exe, powershell_ise.exe, or via the Win+R shortcut;
  • if you are on Linux/macOS, run the suggested command below from the default terminal (like bash or zsh).

If you are using the version of PSReadLine that ships with Windows PowerShell, you need to run: powershell -noprofile -command "Install-Module PSReadLine -Force -SkipPublisherCheck -AllowPrerelease". Note: you will need to make sure PowershellGet is updated before running this command.

If you are using the version of PSReadLine that ships with PowerShell 6+ versions, you need to run: <path-to-pwsh-executable> -noprofile -command "Install-Module PSReadLine -Force -SkipPublisherCheck -AllowPrerelease".

If you've installed PSReadLine yourself from the PowerShell Gallery, you can simply run: powershell -noprofile -command "Update-Module PSReadLine -AllowPrerelease" or <path-to-pwsh-executable> -noprofile -command "Update-Module PSReadLine -AllowPrerelease", depending on the version of PowerShell you are using.

If you get an error like:

Remove-Item : Cannot remove item
C:\Users\{yourName}\Documents\WindowsPowerShell\Modules\PSReadLine\Microsoft.PowerShell.PSReadLine.dll: Access to the path
'C:\Users\{yourName}\Documents\WindowsPowerShell\Modules\PSReadLine\Microsoft.PowerShell.PSReadLine.dll' is denied.

or a warning like:

WARNING: The version '2.0.0' of module 'PSReadLine' is currently in use. Retry the operation after closing the applications.

Then you didn't kill all the processes that loaded PSReadLine.

Usage

To start using, just import the module:

Import-Module PSReadLine

To use Emacs key bindings, you can use:

Set-PSReadLineOption -EditMode Emacs

To view the current key bindings:

Get-PSReadLineKeyHandler

There are many configuration options, see the options to Set-PSReadLineOption. PSReadLine has help for it's cmdlets as well as an about_PSReadLine topic - see those topics for more detailed help.

To set your own custom keybindings, use the cmdlet Set-PSReadLineKeyHandler. For example, for a better history experience, try:

Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward
Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward

With these bindings, up arrow/down arrow will work like PowerShell/cmd if the current command line is blank. If you've entered some text though, it will search the history for commands that start with the currently entered text.

To enable bash style completion without using Emacs mode, you can use:

Set-PSReadLineKeyHandler -Key Tab -Function Complete

Here is a more interesting example of what is possible:

Set-PSReadLineKeyHandler -Chord '"',"'" `
                         -BriefDescription SmartInsertQuote `
                         -LongDescription "Insert paired quotes if not already on a quote" `
                         -ScriptBlock {
    param($key, $arg)

    $line = $null
    $cursor = $null
    [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)

    if ($line.Length -gt $cursor -and $line[$cursor] -eq $key.KeyChar) {
        # Just move the cursor
        [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($cursor + 1)
    }
    else {
        # Insert matching quotes, move cursor to be in between the quotes
        [Microsoft.PowerShell.PSConsoleReadLine]::Insert("$($key.KeyChar)" * 2)
        [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState([ref]$line, [ref]$cursor)
        [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition($cursor - 1)
    }
}

In this example, when you type a single quote or double quote, there are two things that can happen. If the character following the cursor is not the quote typed, then a matched pair of quotes is inserted and the cursor is placed inside the the matched quotes. If the character following the cursor is the quote typed, the cursor is simply moved past the quote without inserting anything. If you use Resharper or another smart editor, this experience will be familiar.

Note that with the handler written this way, it correctly handles Undo - both quotes will be undone with one undo.

The sample profile file has a bunch of great examples to check out. This file is included when PSReadLine is installed.

See the public methods of [Microsoft.PowerShell.PSConsoleReadLine] to see what other built-in functionality you can modify.

If you want to change the command line in some unimplmented way in your custom key binding, you can use the methods:

    [Microsoft.PowerShell.PSConsoleReadLine]::GetBufferState
    [Microsoft.PowerShell.PSConsoleReadLine]::Insert
    [Microsoft.PowerShell.PSConsoleReadLine]::Replace
    [Microsoft.PowerShell.PSConsoleReadLine]::SetCursorPosition

Developing and Contributing

Please see the Contribution Guide for how to develop and contribute.

Building

To build PSReadLine on Windows, Linux, or macOS, you must have the following installed:

  • .NET Core SDK 2.1.802 or a newer version
  • The PowerShell modules InvokeBuild and platyPS

The build script build.ps1 can be used to bootstrap, build and test the project.

  • Bootstrap: ./build.ps1 -Bootstrap
  • Build:
    • Targeting .NET 4.6.2 (Windows only): ./build.ps1 -Configuration Debug -Framework net462
    • Targeting .NET Core: ./build.ps1 -Configuration Debug -Framework netcoreapp2.1
  • Test:
    • Targeting .NET 4.6.2 (Windows only): ./build.ps1 -Test -Configuration Debug -Framework net462
    • Targeting .NET Core: ./build.ps1 -Test -Configuration Debug -Framework netcoreapp2.1

After build, the produced artifacts can be found at <your-local-repo-root>/bin/Debug. In order to isolate your imported module to the one locally built, be sure to run pwsh -NonInteractive -NoProfile to not automatically load the default PSReadLine module installed. Then, load the locally built PSReadLine module by Import-Module <your-local-repo-root>/bin/Debug/PSReadLine/PSReadLine.psd1.

Change Log

The change log is available here.

Licensing

PSReadLine is licensed under the 2-Clause BSD License.

Code of Conduct

Please see our Code of Conduct before participating in this project.

Security Policy

For any security issues, please see our Security Policy.

psreadline's People

Contributors

adityapatwardhan avatar andrewcromwell avatar andrewducker avatar andyleejordan avatar bingbing8 avatar cbadke avatar daxian-dbw avatar ecsousa avatar jameswtruher avatar jazzdelightsme avatar jianyunt avatar jsoref avatar jstarks avatar laoujin avatar lzybkr avatar msftrncs avatar mvkozlov avatar nightroman avatar oising avatar parkovski avatar powercode avatar seeminglyscience avatar springcomp avatar srdubya avatar staxmanade avatar stevel-msft avatar stevenbucher98 avatar theaquamarine avatar tylerleonhardt avatar vors avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

psreadline's Issues

Tab Completion of Lines with NewLine Character

When I do something like the following:

[1] Get-Alias `
| Out-Null
[2] #Out

The output shows Get-Alias `โ—™| Out-Null

Also, it spits out, in some cases 1000 lines for me, maybe there should be a limit on the number of returned items?

Copy-paste of large body of code can't be interrupted

Repro

  • copy large body of a Powershell script (~100 lines).
  • paste into the console and watch it paint itself
  • try to cancel with Ctrl+C - nothing happens, the text would still slowly appear on the screen

And pasting takes significant amount of time. You can see chars appearing one by one as if there is 100ms delay between each character render.

Is there a way find out what EditMode is set?

I think I'd like a hot key to cycle through edit modes. Something like this.

Set-PSReadlineKeyHandler -BriefDescription 'swap modes' -Key 'ctrl+m' -Handler {

    $mode="windows"
    if (Get-PSReadlineOption.EditMode -eq "windows") {
        $mode="emacs"
    }

    Set-PSReadlineOption -EditMode $mode
 }

Add support for a help mode i.e. standard key-binding to dump KeyHandlers

I think of this as the "help/usage" mode for the current keyboard bindings. As such for the CMD mappings, it should probably be something like Ctrl+/ - which is the ? key but we don't want folks to have to press Shift as well.

BTW this should act like the current PossibleCompletions() function where it doesn't interrupt the line editing experience.

Add support for left/right navigation of entire pipeline stages

Say I have this command with the cursor the location highlighted:

C:> Get-Process | Where Handles -gt >><< 500 | Format-Table ProcessName,Handles

We have LeftArrow/RightArrow to move a char at a time and Ctrl+Left/RightArrow to jump a word at a time. Considering the fundamental pipeline stages nature of PowerShell, it would be handy to be able to jump backward and forward through the pipeline stages using say Ctrl+Shift+Left/RightArrow. Pressing Ctrl+Shift+LeftArrow in the above example should put the cursor here:

C:> Get-Process | >>W<<here Handles -gt 500 | Format-Table ProcessName,Handles

Pressing the same key binding again would put it here:

C:> >>G<<et-Process | Where Handles -gt 500 | Format-Table ProcessName,Handles

Then pressing Ctrl+Shift+RightArrow twice would put it here:

C:> Get-Process | Where Handles -gt 500 | >>F<<ormat-Table ProcessName,Handles

Ctrl-C does nothing at command prompt

I can normally type something on the commandline and then hit Ctrl-C to show me the prompt again without executing the command I just typed. After I ipmo PSReadLine, that doesn't work any more. Is there a way to add it back? I looked for an existing action to bind Ctrl-C to but I didn't see one that made sense - did I miss it?

ConsoleHost hangs on exit

If PSReadLine module is imported and the exit button is pressed on the window control box then the console window is not closed immediately but hangs for a few seconds.

Ending powershell task also result in hang, however using the exit command or killing powershell, conhost processes do not.

Closing ps tabs in Console2 multi tab host also result in hang.

Add support for brace/paren matching

I would imagine this to work like it does in VS or ISE. Key-binding could be Ctrl+]. It would match both curly braces and parens which PowerShell command lines can be heavy with. An additional option here might be to match quotes as well since it can be confusing sometimes which double quote matches another and same for single quote.

Missing .dll? Install (user) problem?

Hello! I am probably not doing this right, but after downloading and importing the module, I get the following error:

Import-Module : The module to process 'PSReadLine.dll', listed in field 'NestedModules' of module manifest
'C:\Users\Scott\Documents\WindowsPowerShell\Modules\PSReadLine\PSReadLine.psd1' was not processed because no valid module
was found in any module directory.
At C:\Users\Scott\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:8 char:1

  • Import-Module PSReadLine
  • - CategoryInfo          : ResourceUnavailable: (PSReadLine:String) [Import-Module], PSInvalidOperationException
    - FullyQualifiedErrorId : Modules_ModuleFileNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
    
    

Could someone point me in the correct direction? Thank you in advance!

Shift-Backspace should not produce ^H

I often happen to linger on shift when backspacing, which works well in most situations. PSReadLine punishes me with ^H :/.

Not a bug, perhaps, but a usability improvement.

Add support for keyboard selection of text

We can use the mouse to select/mark text but I would love to be able to use the keyboard with the CMD set of bindings. What I'm thinking is something that should be natural to any Windows user. Use Shift+Left/RightArrow to select text starting from the current position to the left or right, one character at a time. Use Shift+Ctrl+Left/RightArrow to select text from the current position whole words at a time.

Once text is selected (marked), the user should be able to execute:

  • Delete to remove the text but leave the clipboard in tact. This is an important point because the clipboard may have text in it that I want to use to replace the text I deleted. And if there is an undo/redo stack then an accidental Delete without going to the clipboard is easy to recover from.
  • Ctrl+X should remove the text and copy it to the clipboard.
  • Ctrl+Shift+C should just copy the text to the clipboard
  • Ctrl+V should replace the selected text with whatever text is in the clipboard.

Add support for KillWord & KillBackwordWord to CMD key bindings

I propose these two bindings be added to the default CMD mappings:

Set-PSReadlineKeyHandler -Key Ctrl+Delete -BriefDescription KillWord -Handler {
[PSConsoleUtilities.PSConsoleReadLine]::KillWord()
}
Set-PSReadlineKeyHandler -Key Ctrl+Shift+Delete -BriefDescription KillBackwardWord -Handler {
[PSConsoleUtilities.PSConsoleReadLine]::KillBackwardWord()
}

I don't believe these should interact with the clipboard just as CMD's Ctrl+Home/End do not interact with the clipboard. If there is an undo/redo stack then the effects of accidental deletions are greatly minimized by a Ctrl+Z undo. :-)

BTW Ctrl+Delete to delete a word is consistent with the Visual Studio editor. And Shift is commonly used with Ctrl to change direction of a command.

Double tab after space erases line

Pressing tab twice after a space (for example, when trying to look for files in the current directory) causes the entire line to be erased.

Example:
powershell -noprofile
PS1> dir

Console now shows:
PS1>

Colorized Prompts using Write-Host don't work as expected

When using Write-Host to colorize the prompt (the only known method of colorizing the prompt in powershell), the prompt gets clobbered. This makes PSReadLine less able to emulate the goodness of bash and friends.

Possible hack: Allow a variable called $PromptLength (which the Prompt function is required to update) to communicate to PSReadline where the cursor position should be.

More principled fixes may also be possible.

Strange reordering of text when pasting into console

I'm seeing the weirdest thing when I paste into a console: it reorders the text. It appears to do this in a deterministic way, too, as the results are always the same for a given piece of text.

For example, if I copy "abcdefg" to the clipboard from Notepad, then paste it into a Powershell console with PSReadLine imported, I get "acegdbf". If I paste in "abcdefg12345" I get "aceg24bf3d51".

This reproduces with a raw Powershell shell - console mode, running with -noprofile, simply importing the module and nothing further. Powershell 3.0 x64 under Windows 7.

Text pasting is slow

Using the console host text pasting feature (powershell.exe -> window context menu -> edit -> paste) takes exponentially more time as the pasted text is longer.

I haven't investigated the problem deeply, but it seems the context menu pasting pushes the text from the clipboard to Powershell char by char.

I found out that PSReadline enables the CTRL-V shortcut, what is a nice workaround for this problem. However, if I wanted to use the paste feature of a custom console host (e.g. ConsoleZ) it would paste the text char by char too.

Provide a way to prompt for input from a custom binding

I have a line of PowerShell on the screen and want to do a find/replace.

ctrl+e,r

Is there a way to in a handler to suspend typing into the console, capture the input that is typed next and when enter is pressed execute and return back to console input?

Tab completion for command parameters shows invalid candidates

I can't see immediately why this happens, but here's a repro:

# this works, in that -dingtone is not shown as a candidate
set-psreadlineoption -dingtone foo -ding<tab>

# this does not work, in that it shows the parameter repeatedly as a choice
set-psreadlineoption -addtohistoryhandler foo -addtohistory<tab>

A cursory look at parameter metadata yield no clues, sorry!

#<TAB> needs a limit on the number of returned results

Feature request: A configuration option to limit the number of matching history items for a Hash+regex history grepping.

Why: Pressing # completely hoses your terminal for several minutes if you have a very large history loaded.

Steps to repro:

  • Load ~30k lines of history using Add-History
  • Press #
  • Press TAB (This will match all items in the history)
  • Observe 30k lines of history being slowly dumped to your screen, which cannot be killed via Ctrl+C

GetKeyHandlers needs to be added to ValidateSet attribute

If I try to add a keybinding to GetKeyHandlers like so:

Set-PSReadlineKeyHandler -Key Ctrl+/ -Function GetKeyHandlers    

I get this error:

Set-PSReadlineKeyHandler : Cannot validate argument on parameter 'Function'. The argument "GetKeyHandlers" does not
belong to the set "AcceptLine,AddLine,BackwardChar,BackwardDeleteChar,BackwardDeleteLine,BackwardKillLine,BackwardWord,
BeginningOfHistory,BeginningOfLine,CancelLine,Complete,DeleteChar,DisableDemoMode,EmacsBackwardWord,EmacsForwardWord,En
ableDemoMode,EndOfHistory,EndOfLine,ExchangePointAndMark,ForwardChar,ForwardDeleteLine,ForwardWord,HistorySearchBackwar
d,HistorySearchForward,KillBackwardWord,KillLine,KillWord,NextHistory,Paste,PossibleCompletions,PreviousHistory,Redo,Re
vertLine,SetKeyHandler,SetMark,TabCompleteNext,TabCompletePrevious,Undo,Yank,YankPop" specified by the ValidateSet
attribute. Supply an argument that is in the set and then try the command again.
At C:\Users\hillr\Documents\WindowsPowerShell\profile.ps1:25 char:63

  • Set-PSReadlineKeyHandler -Key Ctrl+/            -Function GetKeyHandlers
    
  •                                                           ~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [Set-PSReadlineKeyHandler], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationError,PSConsoleUtilities.SetKeyHandlerCommand

nice to have: import history at module load

I noticed right off that my (ghy).length is greater than the scrollback buffer after loading psreadline. Would be cool if it were to grab everything in the history buffer, especially if I'm doing something outside of my session to persist these.

Poor performance of closing PowerShell

When this module is imported and I close PowerShell by simply closing the console window I get a pause of about six seconds before the window actually closes. Not importing the module fixes this, as does removing the module prior to closing the console window or using exit to close PowerShell.

I do think however, that it should not matter how you close PowerShell.

Enh Req: How about a standard cmd mapping for RevertLine => Ctrl+L

Yeah I know and have set this up for myself but it would be nice to count on this in the standard mapping when I'm on another machine with this module installed. I've always loved the VS Ctrl+L keyboard shortcut to kill the entire current line.

BTW I'm guessing here that RevertLine is the right function to call. It "seems" to do the right thing.

Enh Req: addtional shortcuts to supercharge the CMD line editing experience.

I would like to see folks who know how to use the standard CMD keybindings to be able to use the CMD mappings but have access to new bindings thereby giving them an even better line editing experience than CMD. While you could point them at the Emacs mode I think this defeats the goal of an "easy onramp". Here is what I suggest to add to the default CMD set:

Set-PSReadlineKeyHandler -Key Ctrl+Home -BriefDescription BackwardKillLine -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::BackwardKillLine()
}
Set-PSReadlineKeyHandler -Key Ctrl+End -BriefDescription KillLine -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::KillLine()
}
Set-PSReadlineKeyHandler -Key Ctrl+Delete -BriefDescription KillWord -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::KillWord()
}
Set-PSReadlineKeyHandler -Key Ctrl+Shift+Delete -BriefDescription KillBackwardWord -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::KillBackwardWord()
}

As for selecting characters to copy to the clipboard, I should be able to use Shift+Left/RightArrow to select a range of text. Shift+Home should select to the beginning of the line. Shift+UpArrow should continue that selection up by one line and Shift+DownArrow should continue that selection down by one line (inverting selection if moving over line that was selected). Then Ctrl+C should copy that to the clipboard, Ctrl+X would cut the text to the clipboard and Delete would just delete the text with no impact to the clipboard (of course, it would go on the undo stack). :-)

Also Ctrl+? (or maybe that is Ctrl+/ so no shift is required to get to the ?) should dump the current key handlers (bindings) in the same way you show possible completions with Ctrl+Space i.e. don't disrupt the current line editing experience. This is for when I forget what the keybinding is for a command.

Partial tab completion, like sh

Is it possible to modify the completion of filenames so that it completes to the point where there are alternatives, like in sh? An additional tab press gives you the alternatives. This would really help when browsing deeply namespaced source trees, for example.

I'm asking this without any knowledge of how the completion is done โ€“ perhaps it's provided by PowerShell, in which case I'll have to take it up with Mr. Snover :).

Can't declare Ctrl+Question key binding

If I attempt this I get the following error:

Set-PSReadlineKeyHandler : Cannot process argument transformation on parameter 'Key'. Unrecognized key 'question'.
Please use a character literal or a well-known key name from the System.ConsoleKey enumeration.
At C:\Users\Keith\Documents\WindowsPowerShell\profile.ps1:9 char:35

  • Set-PSReadlineKeyHandler -Key Ctrl+Question -BriefDescription GetKeyHandlers ...
    
  •                               ~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [Set-PSReadlineKeyHandler], ParameterBindingArgumentTransformationExcep
      tion
    • FullyQualifiedErrorId : ParameterArgumentTransformationError,PSConsoleUtilities.SetKeyHandlerCommand

This is my handler decl:

Set-PSReadlineKeyHandler -Key Ctrl+Question -BriefDescription GetKeyHandlers -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::GetKeyHandlers()
}

Bash-like reverse i-search

This isn't a big one, since the backward history search in PSReadline is really quite satisfactory.

But... I know PSReadline 0.x had this feature and now it doesn't. Was there something technical standing in the way of putting this in 1.x? Or might this make a come back at some point?

Consider adding [PSConsoleUtilities.TokenClassification]::All member

Having to set the background colour with set-psreadlineoption one token at a time is very tedious. While the foreground colours are likely to be different for each token, the background colour is likely to be the same:

ps> set-psreadlineoption -token all -backgroundcolor black

The type initializer for 'PSConsoleUtilities.PSConsoleReadLine' threw an exception.

I'm running Powershell 3.0 on .NET 4.0 on Windows 7 x64. I was using the zipfile released Sept 13th and I wasn't having this issue, but after upgrading to the zipfile released yesterday (Oct 14th), I am seeing error messages.

When I load the module, it completes with no errors. However, if I run any of the PSReadline cmdlets, like get-psreadlinekeyhandler or set-psreadlineoption -editmode emacs, it gives me errors like this one:

Get-PSReadlineKeyHandler : The type initializer for 'PSConsoleUtilities.PSConsoleReadLine' threw an exception.
At line:1 char:1
+ Get-PSReadlineKeyHandler
+ ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-PSReadlineKeyHandler], TypeInitializationException
    + FullyQualifiedErrorId : System.TypeInitializationException,PSConsoleUtilities.GetKeyHandlerCommand

I am seeing this even on Powershell sessions that I start with the -noprofile command line option.

CD in a -Handler does not update my powershell prompt

I have the latest from the zip.

After pressing the chord, my prompt does not show the new location. The set-location did execute correctly.

The next time I press enter the prompt updates.

Set-PSReadlineKeyHandler -Chord 'ctrl+c,ctrl+q' -BriefDescription 'quickgraph' -Handler { cd C:\posh\QuickGraph }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.