r/PowerShell • u/themor69 • May 22 '26
Question Fish-Like Syntax Highlighting
The Fish shell for Linux (as well as the zsh-syntax-highlighting package for zsh) has a command syntax highlighting feature that is quite helpful. PowerShell has this somewhat with the PSReadLine feature, but it's missing a critical part that I miss from Fish. In Fish, when you would type a command that was incorrect, as you were typing it would highlight the command as one color if it was invalid, and another if it was valid (valid meaning builtin or in path). Is there any way to get this functionality in PowerShell (7.0+)?
12
Upvotes
View all comments
Show parent comment
2
u/Thotaz May 22 '26
The problem is the lack of control we have over the coloring. Getting the commands and determining if it's valid is trivial (if we can accept a few false negatives). Once per session you just run
Get-Commandto list all commands and save them in a hashset, then you parse the current input and check if each command is in the hashset.If we also want to handle newly added commands (. dot sourcing a script, updating
$env:path, etc.) then we could put the hashset update function in thepromptfunction. That only leaves relative paths unaccounted for.