Powershell hyphen argument color

You're looking for the Parameter token kind:

Set-PSReadlineOption -TokenKind Parameter -ForegroundColor Red

The above will color parameter tokens (like -a) red, but not bare string tokens prefixed with -- (like --All), since they're technically not considered parameter tokens by the parser.


As Rabeez Riaz notes, in PSReadLine 2.0 the syntax is slightly different:

Set-PSReadLineOption -Colors @{ Parameter = 'Red' }

The new syntax allows you to set multiple token colors simultaneously:

Set-PSReadLineOption -Colors @{
  Parameter  = 'Red'
  String     = 'Cyan'
  Command    = 'Green'
}

What you are looking for is something like this:

Set-PSReadLineOption -Colors @{"Parameter"="#ff81f7"}