Add different color for correct/incorrect command · Issue #3439 · PowerShell/PSReadLine · GitHub
Skip to content

Add different color for correct/incorrect command #3439

Open

Description

Description of the new feature/enhancement

Add a different color for highlighting if the first word of a command is correct or incorrect (running the command won't result in "The term 'abcedf' is not recognized...").

For example, assuming an environment where v is not a valid program but vi is, typing a command such as v file.txt will highlight the v in a different color to show that v is not a valid command. When typing vi file.txt, vi will have a different color to show that it is a valid command.

Here is an example from fish shell:

Screenshot from 2022-09-19 03-42-16

Activity

  1. ghost added
    Needs-Triage 🔍It's a new issue that core contributor team needs to triage.
    on Sep 19, 2022
  2. dkaszews commented on Oct 21, 2022

    @dkaszews
    Contributor

    What if the first word is a variable? Should we check if it exists? And what if it's a file instead? I believe typing just a filename will open it in default program, same as if given as an argument to Start-Process (can't test it over SSH).

    Also, should this coloring apply only to start of the line, or any command? It could be complicated if validity of it changes mid-line, e.g. $env:PATH += $path_to_v; v or Set-Alias 'v' 'vim'; v.

  3. TransientError commented on Oct 21, 2022

    @TransientError

    Fish has a different coloring for variables, which is activated as soon as you type '$'. It seems to not change colors with files unless prefaced with './' and the file is executable. And it's only at the first word.

    After using it for a long time, I've found it very useful for catching mistakes before executing. I'd love to see this in PowerShell as well.

  4. davidsanchez222 commented on Jun 23, 2026

    @davidsanchez222

    Hello, I see this issue hasn't been touched in years. I use PSReadLine with Powershell on my Windows work laptop. This is a feature I am missing that I have in zsh on my personal. Would a PR be accepted that implements this behavior?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions