Skip to content

What is the correct way to write a clear final separator? #69

@jeremytwfortune

Description

@jeremytwfortune

This code

$line += ([PoshCode.Pansies.Text]@{
Object = "$([char]27)[49m$ColorSeparator&Clear;"
ForegroundColor = $LastBackground
})

add a final $ColorSeparator to the generated line. This works well when the last prompt has a background color like those displayed in the readme.

However, I like keeping all of my colors up top and print a null background for the last item on the prompt array.

image

I'm explicitly setting $Null colors to allow this.

Set-PowerLinePrompt -Colors $Null, Null

However, if a $ColorSeparator is added on the end, it appears as though the text is rendered with some other background color. This is the effect.

image

I can't seem to find a public way to alter this separator's background color. To achieve the working screenshot I showed above where the background color of the separator is clear, I added a wrapper to check the last background:

if ($Null -ne $LastBackground) {
    $line += ([PoshCode.Pansies.Text]@{
        Object = "$([char]27)[49m$ColorSeparator&Clear;"
        ForegroundColor = $LastBackground
    })
}

which works because the final block sets $LastBackground.

Is there a better, public way to control this last separator?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions