PSReadLine | A bash inspired readline implementation for PowerShell | Command Line Interface library

 by   PowerShell C# Version: v2.3.1-beta1 License: BSD-2-Clause

kandi X-RAY | PSReadLine Summary

kandi X-RAY | PSReadLine Summary

PSReadLine is a C# library typically used in Utilities, Command Line Interface applications. PSReadLine has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.

This module replaces the command line editing experience of PowerShell for versions 3 and up. It provides:. 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.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              PSReadLine has a medium active ecosystem.
              It has 3167 star(s) with 278 fork(s). There are 80 watchers for this library.
              There were 1 major release(s) in the last 12 months.
              There are 172 open issues and 3028 have been closed. On average issues are closed in 439 days. There are 8 open pull requests and 0 closed requests.
              It has a neutral sentiment in the developer community.
              The latest version of PSReadLine is v2.3.1-beta1

            kandi-Quality Quality

              PSReadLine has 0 bugs and 0 code smells.

            kandi-Security Security

              PSReadLine has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              PSReadLine code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              PSReadLine is licensed under the BSD-2-Clause License. This license is Permissive.
              Permissive licenses have the least restrictions, and you can use them in most projects.

            kandi-Reuse Reuse

              PSReadLine releases are available to install and integrate.
              Installation instructions, examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
            Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PSReadLine
            Get all kandi verified functions for this library.

            PSReadLine Key Features

            No Key Features are available at this moment for PSReadLine.

            PSReadLine Examples and Code Snippets

            No Code Snippets are available at this moment for PSReadLine.

            Community Discussions

            QUESTION

            Accept part of the autocompletion
            Asked 2022-Feb-28 at 06:36

            I have recently got myself a new Windows 11 laptop, and started exploring powershell. Never used it before on Windows, but I'm a frequest user of zsh in Mac so not completely new.

            I upgraded Powershell to 7.2.1, but noticed that the auto-suggestion type feature that I'm used to with Oh My Zsh is missing. After searching a bit, I installed PSReadLine, and setup my profile using the following:

            ...

            ANSWER

            Answered 2022-Feb-28 at 06:36

            From the about_PSReadLine docs

            AcceptNextWordSuggestion
            Accepts the next word of the inline suggestion from Predictive IntelliSense. This function can be bound with Ctrl+F by running the following command.

            Source https://stackoverflow.com/questions/71283083

            QUESTION

            How do you edit the command line in an external editor?
            Asked 2022-Feb-21 at 08:46
            tl;dr

            I want to find a Powershell version of the bash edit-and-execute-command widget or the zsh edit-command-line widget.

            Background

            Short commands get executed directly on the command-line, long complicated commands get executed from scripts. However, before they become "long", it helps to be able to test medium length commands on the command-line. To assist in this effort, editing the command in an external editor becomes very helpful. AFAIK Powershell does not support this natively as e.g. bash and zsh do.

            My current attempt

            I am new to Powershell, so I'm bound to make many mistakes, but I have come up with a working solution using the features of the [Microsoft.Powershell.PSConsoleReadLine] class. I am able to copy the current command-line to a file, edit the file, and then re-inject the edited version back into the command-line:

            ...

            ANSWER

            Answered 2022-Feb-19 at 12:16

            This code has some issues:

            • Temp path is hardcoded, it should use $env:temp or better yet [IO.Path]::GetTempPath() (for cross-platform compatibility).
            • After editing the line, it doesn't replace the whole line, only the text to the left of the cursor. As noted by mklement0, we can simply replace the existing buffer instead of erasing it, which fixes the problem.
            • When using the right parameters for the editor, it is not required to create a job to wait for it. For VSCode this is --wait (-w) and for gvim this is --nofork (-f), which prevents these processes to detach from the console process so the PowerShell code waits until the user has closed the editor.
            • The temporary file is not deleted after closing the editor.

            Here is my attempt at fixing the code. I don't use gvim, so I tested it with VSCode code.exe. The code below contains a commented line for gvim too (confirmed working by the OP).

            Source https://stackoverflow.com/questions/71174012

            QUESTION

            Set-PSReadLineOption: A parameter cannot be found that matches parameter name 'PredictionViewStyle'
            Asked 2022-Feb-18 at 08:33

            I'm trying to change the -PredictionViewStyle option of PSReadline, but I got the error "Set-PSReadLineOption: A parameter cannot be found that matches parameter name 'PredictionViewStyle'."

            It's a fresh install and Set-PSReadLineOption -PredictionSource History works.

            Any suggestion, please?

            ...

            ANSWER

            Answered 2022-Feb-18 at 08:33

            Restarting my shell solved it...

            Source https://stackoverflow.com/questions/71170461

            QUESTION

            Powershell arrayslicing Get-PSReadLine
            Asked 2022-Jan-09 at 21:51

            trying to array slice the get-psreadlineoption command. I want to select all strings containing the word 'Color' and then input those to 'set-psreadline' to set all colors. I do not understand how this all works in powershell. It's an array, right? I can just loop over it like this:

            foreach($a in $i) { $i; if ($i -contains 'MemberColor') {$i;} }

            But that gives no output. I also cannot access it as an array:

            get-psreadlineoption[21..36] get-psreadlineoption['EditMode']

            Does not work. Basically what I want to do is:

            foreach (get-psreadlines[21..36]) { $array = append() } foreach ($a in $array) { set-psreadline($a, ...)}

            How would I go about doing this?

            (P.S. I just want to set all those colors to the same color in a concise manner as possible)

            ...

            ANSWER

            Answered 2022-Jan-09 at 21:51

            The solution depends on what version of the PSReadLine module you're using:

            • PSReadline v2.x, which ships with PowerShell (Core) 7+.
            • PSReadline v1.x, which Windows PowerShell versions ship with in Windows 10+ / Windows Sever 2016+, although it is possible to install 2.x on demand in Windows PowerShell 5.0 and 5.1 (Install-Module PSReadLine)

            Use (Get-Module PSReadLine).Version.ToString() to see which version you're using.

            PSReadline v2.x solution:

            To get the names of all color properties, via filtering the names by those ending in color (case-insensitively), use reflection, which PowerShell facilitates via the intrinsic .psobject property:

            Source https://stackoverflow.com/questions/70578032

            QUESTION

            PSReadLine throw exception after upgrading to PS 7.2
            Asked 2021-Nov-19 at 17:21

            Exception thrown after upgrading to Powershell 7.2.0 while using PSReadLine

            ...

            ANSWER

            Answered 2021-Nov-19 at 17:21

            As mentioned in this thread, the issue can be fixed by

            This issue was fixed in 2.2.0-beta3 version of PSReadLine. You can fix this by upgrading to the latest 2.2.0-beta4 version of PSReadLine. Instructions for doing so:

            1: stop all instances of pwsh.

            2: from cmd.exe run:

            Source https://stackoverflow.com/questions/70029854

            QUESTION

            Different cursor for different Vim modes in Powershell
            Asked 2021-Jul-09 at 12:10

            I added Vim bindings to my Powershell using PSReadline module as shown in this Server Fault post. The problem after this was that there wasn't any visual indicator for the different modes of Vim.

            I just wanted different cursors for the 'command' and the other modes. Block cursor for command mode and line cursor for other modes. So I searched around and found this in the official Microsoft docs: Use ViModeChangeHandler to display Vi mode changes

            ...

            ANSWER

            Answered 2021-Jul-09 at 12:06

            When I was following the instructions given in the Server Fault post I ran:

            Source https://stackoverflow.com/questions/68315479

            QUESTION

            Unable to access SQL Server Management Objects (SMO) Framework in PowerShell
            Asked 2021-Jun-25 at 20:58

            We're calling a PowerShell script on a remote server which returns an enumeration value [Microsoft.SqlServer.Management.Smo.Agent.CompletionResult]. When we run the script on the local machine, the PowerShell script does not know what this enumeration is and fails.

            I have gathered the SqlServer PowerShell Extension NuGet package and its dependencies and attempted to installed it.

            Note, this is for an offline installation.

            Install packages:

            ...

            ANSWER

            Answered 2021-Jun-24 at 13:06

            I finally got there and realised that I needed to simply import the library in my script. I had assumed this would work without as on the remote server there is no import.

            Source https://stackoverflow.com/questions/68114374

            QUESTION

            PSReadLine history doesn't load
            Asked 2021-Jun-05 at 05:48

            I tried to use psreadline today. There is something i don't understand is the history command.

            When I run

            ...

            ANSWER

            Answered 2021-Jun-05 at 03:33

            If this is the only command you are using...

            Source https://stackoverflow.com/questions/67844259

            QUESTION

            Add-AzMetricAlertRuleV2 throw "Couldn't find a metric named..."
            Asked 2021-May-25 at 01:40
            Description

            I'm trying to create new Azure Monitor Alert using PS script. I'm using MS documentation here: https://docs.microsoft.com/en-us/powershell/module/az.monitor/add-azmetricalertrulev2?view=azps-5.9.0

            Steps to reproduce

            $condition = New-AzMetricAlertRuleV2Criteria -MetricName "SqlDbDtuUsageMetric" -MetricNameSpace "Microsoft.Sql/servers/databases" -TimeAggregation Average -Operator GreaterThan -Threshold 5

            $act = New-AzActionGroup -ActionGroupId /subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/microsoft.insights/actionGroups/SqlDbDtuUsageAction

            Add-AzMetricAlertRuleV2 -Name "SqlDbDtuUsageAlertGt5" -ResourceGroupName {resource_group} -WindowSize 00:05:00 -Frequency 00:05:00 -TargetResourceId "/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.Sql/servers/{sql_server}/databases/vi{sql_db}" -Description "Alerting when max used DTU is > 20" -Severity 3 -ActionGroup $act -Condition $condition

            Error output

            WARNING: 09:04:18 - *** The namespace for all the model classes will change from Microsoft.Azure.Management.Monitor.Management.Models to Microsoft.Azure.Management.Monitor.Models in future releases. WARNING: 09:04:18 - *** The namespace for output classes will be uniform for all classes in future releases to make it independent of modifications in the model classes. VERBOSE: Performing the operation "Create/update an alert rule" on target "Create/update an alert rule: SqlDbDtuUsageAlertGt5 from resource group: vi-prod-be-cin-rg". Add-AzMetricAlertRuleV2 : Exception type: ErrorResponseException, Message: Couldn't find a metric named metric1. Make sure the name is correct. Activity ID: 3e7e537e-43fc-40ad-8a84-745df33e1668., Code: BadRequest, Status code:BadRequest, Reason phrase: BadRequest At line:1 char:1

            • Add-AzMetricAlertRuleV2 -Name "SqlDbDtuUsageAlertGt5" -ResourceGroupN ...
            • ...

            ANSWER

            Answered 2021-May-25 at 01:40

            According to the error, the MetricNameSpace Microsoft.Sql/servers/databases does not contain metric SqlDbDtuUsageMetric. Regarding the supported metric, please use the following command to get

            Source https://stackoverflow.com/questions/67667463

            QUESTION

            Powershell Linux Sharepoint Management
            Asked 2021-May-16 at 11:13

            I installed powershell (pwsh) on Ubuntu 20.4. I am trying to manage some Sharepoint stuff. I did the following:

            ...

            ANSWER

            Answered 2021-May-16 at 11:13

            The Sharepoint module is for Windows PowerShell Edition and not for PowerShell Core Edition :

            Source https://stackoverflow.com/questions/67525890

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install PSReadLine

            There are multiple ways to install PSReadLine.
            You will need the 1.6.0 or a higher version of PowerShellGet to install the latest prerelease version of PSReadLine.
            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.
            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.

            Support

            Please see the Contribution Guide for how to develop and contribute.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries

            Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link

            Explore Related Topics

            Consider Popular Command Line Interface Libraries

            ohmyzsh

            by ohmyzsh

            terminal

            by microsoft

            thefuck

            by nvbn

            fzf

            by junegunn

            hyper

            by vercel

            Try Top Libraries by PowerShell

            PowerShell

            by PowerShellC#

            PSScriptAnalyzer

            by PowerShellC#

            vscode-powershell

            by PowerShellTypeScript

            platyPS

            by PowerShellC#

            GraphicalTools

            by PowerShellC#