Code Monkey home page Code Monkey logo

psreadline's Introduction

PSReadLine

This module replaces the command line editing experience in PowerShell.exe. It provides:

  • Syntax coloring
  • Simple syntax error notification
  • A better 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)
  • Emacs yank/kill ring
  • PowerShell token based "word" movement and kill

Many planned features are not yet implemented, but in it's current state, the module is very usable.

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

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 -BriefDescription HistorySearchBackward -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::HistorySearchBackward()
}
Set-PSReadlineKeyHandler -Key DownArrow -BriefDescription HistorySearchForward -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::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 -BriefDescription Complete -Handler { 
    [PSConsoleUtilities.PSConsoleReadLine]::Complete()
}

See the public methods of [PSConsoleUtilities.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:

    [PSConsoleUtilities.PSConsoleReadLine]::GetBufferState
    [PSConsoleUtilities.PSConsoleReadLine]::SetBufferState

psreadline's People

Contributors

lzybkr avatar oising avatar

Watchers

James Cloos avatar Nathan Morell avatar  avatar

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.