Điểm qua PowerShell/PSReadLine: 4.4k sao trên GitHub, viết chủ yếu bằng C#. A bash inspired readline implementation for PowerShell
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
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 and Upgrading
You will need the 1.6.0 or a higher version of PowerShellGet to install or upgrade to the latest prerelease version of PSReadLine.
PowerShell 6+ already has a higher version of PowerShellGet built-in.
However, 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 install or upgrade to the latest prerelease version of PSReadLine by running
[!NOTE] Prerelease versions will have newer features and bug fixes, but may also introduce new issues.
Usage
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 its 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:
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:
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 VSCode, 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:
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.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/PowerShell/PSReadLine là nguồn chính thức.
PowerShell/PSReadLine có bao nhiêu sao?
PowerShell/PSReadLine có 4.4k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/PowerShell/PSReadLine. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
PowerShell/PSReadLine có phải mã nguồn mở không?
Có — PowerShell/PSReadLine phát hành theo license BSD-2-Clause, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/PowerShell/PSReadLine.
PowerShell/PSReadLine còn đang phát triển không?
Commit gần nhất trên PowerShell/PSReadLine là 5 tháng trước (theo timestamp GitHub). Repo có 341 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
PowerShell/PSReadLine dùng license gì?
PowerShell/PSReadLine phát hành theo license BSD-2-Clause. Nên mở file LICENSE trên GitHub để xác nhận — license metadata đôi khi lệch với thực tế dự án.
PowerShell/PSReadLine là gì?
PowerShell/PSReadLine (PowerShell/PSReadLine) là dự án C# trên GitHub. Theo mô tả gốc: A bash inspired readline implementation for PowerShell
PowerShell/PSReadLine viết bằng ngôn ngữ gì?
PowerShell/PSReadLine chủ yếu viết bằng C#. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về PSReadLine?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về PSReadLine.