Git Product home page Git Product logo

powerline's Introduction

Build on push

PowerLine - Beautiful, Powerful, PowerShell prompts

Install

You can install PowerLine from the PowerShell gallery, using the following commands:

Install-Module PANSIES -AllowClobber
Install-Module PowerLine
Import-Module PowerLine

NOTE: My PANSIES module for ANSI Escape Sequences is required, and because of how PowerShellGet works, you need to install it separately, as it includes an improved Write-Host (which is faster, and fully backwards compatible), and therefore requires the -AllowClobber switch when installing.

First use configuration

There are quite a few options for PowerLine, and you're going to want to set some of them immediately to take full advantage. Check out the ./Source/Examples for some ideas.

Set-PowerLinePrompt -SetCurrentDirectory -RestoreVirtualTerminal -Newline -Timestamp -Colors "#FFDD00", "#FF6600"

Prompt ScreenShot

You can change the colors by running just that part of the command:

Set-PowerLinePrompt -Colors "#00DDFF", "#0066FF"

Prompt ScreenShot

You can review (or modify) your current blocks by using $prompt, and check which colors it's using with $prompt.colors, but there are also commands like the one above to help out.

Now you can add additional blocks to your prompt, even inserting them into the list. Blocks without output are automatically hidden in PowerLine, so you can write a conditional block like this:

Add-PowerLineBlock { if($pushed = (Get-Location -Stack).count) { "»$pushed" } }  -Index 1

Prompt ScreenShot

Note that in your PowerLine blocks, there is full support for PANSIES Text, which means colors from it's drives, like $fg:red and named HTML Entities like ♥ and € and now, even emoji and nerdfont named entities -- if you enable them.

There are some helper functions in PowerLine for common things you'd want in your prompt, like Get-ShortenedPath and Get-SegmentedPath as well as Get-Elapsed and Test-Elevation and Test-Success.

Once you start playing with the other options, and get it the way you want, you can save it, and Powerline will re-load it on import in the future:

Export-PowerlinePrompt

For more information about the configuration --particularly how to get the cool angled separators you see in my screenshots using powerline fonts-- you can skip past this explanation of why I wrote the module, but you should also explore the commands, as this external documentation is always lagging behind the implementation.

Why Powerline?

As a PowerShell user
In order to have the right information available
I need to be able to customize my prompt

As a PowerShell module author
In order to give my users the right information
I need to add information to the user's prompt

As an alpha geek
In order to stand out
I want to have a cool prompt!

Currently in PowerShell, the prompt is a function that must return a string. Modules that want to add information to your prompt typically don't even try if you have customized your prompt (see Posh-Git, for example). The goal of PowerLine is to have beautiful custom prompts and let modules add (and remove) information easily.

Your Prompt as a Collection

The core principle of PowerLine 3 is to make your prompt easier to change, and changes easier to undo.

The idea is to assume a $Prompt variable that's a List of ScriptBlock and just join the output of those scriptblocks:

function prompt {
    -join $prompt.Invoke()
}

Why Lists of ScriptBlocks?

  1. The user can easily add or remove information on the fly.
  2. Modules can add (and remove) information as they're imported/removed.
  3. We can customize the look separate from the content.

Take this for example, it's the same as the current default prompt, except split in three parts:

[System.Collections.Generic.List[ScriptBlock]]$Prompt = @(
    { "PS " }
    { $executionContext.SessionState.Path.CurrentLocation }
    { '>' * ($nestedPromptLevel + 1) }
)

This would produce the same output as before, and would have no impact on users who already overwrite the default prompt. In fact, you can switch to this right now, by just putting those two blocks in your profile.

For users:

It's suddenly easy to tweak the prompt. I can remove the unecessary "PS " from the front of my prompt by just running

$Prompt = $Prompt | Select -Skip 1

Or if I wanted to print the current command's HistoryId instead of the "PS", I could just replace that first part:

$Prompt[0] = { "$($MyInvocation.HistoryId) " }

For module authors:

Modules can modify the prompt just as easily. Adding to a list is simpler and easier to undo, plus it's possible for the user to re-order their prompt. Since modules don't have to modify or wrap the actual prompt function, users end up in control.

For example, posh-git can add it's information to the prompt in just one line:

$Prompt.Add({Write-VcsStatus})

And can hook it's own removal to clean up the status:

$MyInvocation.MyCommand.Module.OnRemove = {
    $Prompt.RemoveAll( {param($_) $_.ToString().Trim() -eq "Write-VcsStatus" } )
}

Using PowerLine

Of course, with PowerLine, it's even easier. A module can just run:

Add-PowerLineBlock { Write-VcsStatus } -AutoRemove

Configuration

PowerLine has a lot of flexibility and functionality around output and looks. Because your whole prompt is just a list of script blocks, we can transform your prompt's appearance. You can go from simple to elegant instantly, and then take control of colors and more.

One important aspect of configuring PowerLine is that it supports both the Configuration module and the EzTheme module. It saves it's current configuration when you run Export-PowerLinePrompt and automatically re-imports it when you import the module.

The Configuration Module

As with any module which supports Configuration, you can get the configuration as a hashtable using the Configuration commands:

$Configuration = Get-Module PowerLine | Import-Configuration

You can examine and modify the configuration and then save it back to disk with:

Get-Module PowerLine | Export-Configuration $Configuration

The EzTheme Module

Of course, the EzTheme module supports some of the same functionality as the Configuration module -- it's goal is to support theming lots of modules at once (i.e. with each theme), so you can get your settings with Get-PowerLineTheme which by default will show a preview. You can review the settings by using Format-List, capture them with a variable and modify them (and even preview the modifications). As with any module that supports EzTheme, you can modify the returned object and put it back by piping it to Set-PowerLineTheme.

PowerLine Coloring blocks

The -Colors parameter supports setting the background colors. You can pass a list of colors and PowerLine will loop through them. You can also specify two colors, and PowerLine will generate a gradient between those colors with the same number of steps as you have output blocks.

Basically, each scriptblock which has output (PowerLine cleans up and ignores empty blocks), uses one of those colors, looping back to the first if it runs out. PowerLine automatically selects contrasting colors for the text (foreground) color.

You can set the color with something like this: Set-PowerLinePrompt -Color "#00DDFF","#0066FF"

PowerLine Fonts and Separators

The -PowerLineFont switch requires using a PowerLine font, which is a font that has the extra extended characters with the nice angled separators you see in the screenshots here between colors. There are a lot of monospaced fonts to choose from, and you can even install them all by just cloning the repository and running the install.ps1 script, or you can just pick just one TTF and download and install that.

There are screenshots of all of them here.

If you're not using a PowerLine font, don't use the -PowerLineFont switch, and the module will output common ASCII box characters like โ–Œ as the separators...

These characters are set into a dictionary ([PoshCode.Pansies.Entities]::ExtendedCharacters) when you call Set-PowerLinePrompt.

Prompts as arrays

By default, each ScriptBlock outputs one string, and is colored in one color, with the "ColorSeparator" character between each block.

However, PowerLine also supports blocks which output arrays. When a ScriptBlock outputs an array of strings, they will be separated with the alternate "Separator" instead of the "ColorSeparator".

All you need to to is start adding things to your $Prompt -- you can do that directly on the list, using $Prompt.Add or $Prompt.Insert, or you can use the Add-PowerLine command.

Right-aligned blocks

If you add a scriptblock that outputs just a tab { "`t" }, blocks after that will be right-aligned until the next block which is just a newline { "`n" }.

For Right-aligned blocks, the "ReverseColorSeparator" or "ReverseSeparator" characters are used instead of the "ColorSeparator" and "Separator".

Characters and Custom Entities

PowerLine uses the Pansies module for coloring and output, so it inherits Pansies' support for HTML named entities like ♥ and © or ¢ and numerical unicode character entities in decimal (Ξ) and hexadeximal (Ξ), so you can easily embed characters.

Additionally, Pansies treats the ExtendedCharacters dictionary of characters mentioned earlier as entities, and has an additional EscapeSequences dictionary which maps entity names to a string. Both of these are modifyable and support adding your own characters, which can then be used as named entities with a & and a ; ...

Helper Functions for Prompts

We recommend that modules which want to add information to the prompt create a function which returns a string, and then add a scriptblock wrapping that single function to the $Prompt using Add-PowerLineBlock (or by hand, as shown above).

There are a few extra functions included as part of the PowerLine module:

Cmdlet Description
New-PromptText A wrapper for New-Text that supports changing foreground or background colors based on whether there's an error or whether the session is elevated.
Get-Elapsed Calls Get-History to get a single command (the most recent, or by ID) and returns the difference between the Start and End execution time.
Get-SegmentedPath Converts a path to an array of Pansies Text objects (one for each folder), with a limit on how many folders to return. Truncates and appends an ellipsis.
Get-ShortenedPath Shortens a path to a specified length, with some options for the output
Test-Elevation Returns True if the current session is elevated, false otherwise
Test-Success Returns True if the last command was successful, false otherwise

Helpers for module authors

PowerLine also provides some additional functions for adding and removing from the prompt list so that modules can add without worrying about doubling up. If Posh-git was to actually adopt the code I mentioned earlier, every time you imported it, they would append to your prompt -- and since they're not cleaning up when you remove the module, they would get re-imported automatically whenever you removed the module.

PowerLine gives you an Add-PowerLineBlock which lets you pass in a ScriptBlock and have it added to the prompt only if it's not already there -- which means the user can move it around, and re-import the module without having it show up twice. It even has an -AutoRemove switch which can be used when adding to the PowerLine from a module to automatically remove that block if the module is removed by the user. And of course, there's a Remove-PowerLineBlock which lets you clean up manually.

There is a New-PromptText function which allows you to change the colors based on elevation, or the success of the last command.

Finally, there are separate Test-Success and Test-Elevation functions (which are used by New-PromptText), if you just want to output something conditionally, or deal with it on your own.

Future Plans

If you have any questions, please ask, and feel free to send me pull requests with additional escape sequences, or whatever.

PowerLine now depends on Pansies for color, special characters, etc.

powerline's People

Contributors

andriniaina avatar bgelens avatar dwsr avatar exe-boss avatar jackdcasey avatar jaykul avatar nzbart avatar rkeithhill avatar sf-jarcher avatar xainey avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

powerline's Issues

3.0 modules that update the prompt break the powerline prompt

I understand what is happening here, but I don't really know why:

I set my powerline prompt as:
[System.Collections.Generic.List[ScriptBlock]]$Global:Prompt = @( { if ($Global:IsAdmin) {New-PromptText {"ADMIN"} -BackgroundColor DarkRed -ForegroundColor Yellow}else {"" }}, {New-PromptText {$(Convert-Path -Path $(Get-Location))} -ForegroundColor Cyan -BackgroundColor Magenta} )

Set-PowerLinePrompt -Prompt $Global:Prompt -FullColor -PowerLineFont -Title { "{0} ({1})" -f (Convert-Path $pwd), $pwd.Provider.Name } #-Newline

This works fine, UNTIL I load Zlocation, which plops "Update-ZLocation $pwd" at the top of the prompt function.

So after zLocation does its thing in the prompt, my prompt ends up as PS> (i.e. the default), and $error says:

PS>$error The variable '$Script:PowerLineConfig' cannot be retrieved because it has not been set. The variable '$Script:PowerLineConfig' cannot be retrieved because it has not been set. At line:7 char:9
+ if ($Script:PowerLineConfig.Title) {
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Script:PowerLineConfig:String) [], RuntimeException
+ FullyQualifiedErrorId : VariableIsUndefined

PS>

I don't understand why $Script:PowerLineConfig ends up null after zLocation, but if I add
$Script:PowerLineConfig = $(Get-Module PowerLine|Import-Configuration)

right after [bool]$Script:LastSuccess = $? in prompt.ps1, all is well again (i.e. the configuration is reloaded and $Script.PowerLineConfig.Title doesnt raise an exception).

Req: A community theme repo

First - thank you for this awesome implementation.

As I open this issue, 8 other contributors other than @Jaykul have registered commits, and the project has 465 stars.
With the conservative assessment of 10% actual use and the rest just 'interest', that still puts it at at least 40 active users.

Being rather new to this module, I find the lack of template Themes a bit of a bummer (although, I'm getting the hang of it already).

I would really like to see a community based repo just for Themes.

And as a first goal, we can use a list of themes available in other projects and attempt to create them in PowerLine flavor.

Let us know if this is something you want to creating and manage, or if you prefer this would come from the community ( and if so, would you link to it from your README.md page?)

Write-GitStatusPowerLine not working

Unable to use Write-GitStatusPowerLine within my PowerLine Prompt

PS>Write-GitStatusPowerLine
Unable to find type [RgbColor].
At C:\Program Files\WindowsPowerShell\Modules\PowerLine\2.3.1\PowerLine.psm1:305 char:9
+         [RgbColor]$ForegroundColor,
+         ~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (RgbColor:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Unable to find type [RgbColor].
At C:\Program Files\WindowsPowerShell\Modules\PowerLine\2.3.1\PowerLine.psm1:305 char:9
+         [RgbColor]$ForegroundColor,
+         ~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (RgbColor:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Unable to find type [RgbColor].
At C:\Program Files\WindowsPowerShell\Modules\PowerLine\2.3.1\PowerLine.psm1:305 char:9
+         [RgbColor]$ForegroundColor,
+         ~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (RgbColor:TypeName) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Module info:

PS>Get-Module PSGit, PowerLine | select Name, Version

Name      Version
----      -------
PowerLine 2.3.1
PSGit     2.0.4

Running Windows 10 x64 Enterprise 1702.

PowerLine 3.4.0 fails to read a config that worked with 3.3.0

I've upgraded PowerLine 3.3.0 to 3.4.0 (also forcing Configuration 1.5.0 installation per PoshCode/Configuration#45 (comment)) and PowerLine now fails, with the following error:

Import-Metadata: C:\Users\paulh\Documents\PowerShell\Modules\Configuration\1.5.0\Configuration.psm1:457
Line |
 457 |              Import-Metadata $EnterprisePath @MetadataOptions
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | At C:\Users\paulh\AppData\Roaming\powershell\HuddledMasses.org\PowerLine\Configuration.psd1:10 char:17 +     Colors = @((RgbColor 'Cyan'),(RgbColor 'DarkCyan'),(RgbColor 'Gra โ€ฆ +                 ~~~~~~~~~~~~~~~
     | The command 'RgbColor' is not allowed in restricted language mode or a Data section.  At C:\Users\paulh\AppData\Roaming\powershell\HuddledMasses.org\PowerLine\Configuration.psd1:10 char:35 +     Colors =
     | @((RgbColor 'Cyan'),(RgbColor 'DarkCyan'),(RgbColor 'Gra โ€ฆ +                                   ~~~~~~~~~~~~~~~~~~~ The command 'RgbColor' is not allowed in restricted language mode or a Data section.  At
     | C:\Users\paulh\AppData\Roaming\powershell\HuddledMasses.org\PowerLine\Configuration.psd1:10 char:57 + โ€ฆ  = @((RgbColor 'Cyan'),(RgbColor 'DarkCyan'),(RgbColor 'Gray'),(RgbCo โ€ฆ +
     | ~~~~~~~~~~~~~~~ The command 'RgbColor' is not allowed in restricted language mode or a Data section.  At C:\Users\paulh\AppData\Roaming\powershell\HuddledMasses.org\PowerLine\Configuration.psd1:10 char:75 + โ€ฆ
     | ,(RgbColor 'DarkCyan'),(RgbColor 'Gray'),(RgbColor 'DarkGray'),(RgbCo โ€ฆ +                                             ~~~~~~~~~~~~~~~~~~~ The command 'RgbColor' is not allowed in restricted language mode or a Data
     | section.  At C:\Users\paulh\AppData\Roaming\powershell\HuddledMasses.org\PowerLine\Configuration.psd1:10 char:97 + โ€ฆ DarkCyan'),(RgbColor 'Gray'),(RgbColor 'DarkGray'),(RgbColor 'Gray')) +
     | ~~~~~~~~~~~~~~~ The command 'RgbColor' is not allowed in restricted language mode or a Data section.

The Configuration.ps1 in question:

@{
  PowerLineConfig = @{
    PowerLineFont = $True
    SetCurrentDirectory = $True
    DefaultAddIndex = 2
    RestoreVirtualTerminal = $True
    FullColor = $True
    Prompt = @((ScriptBlock ' New-PromptText { "&OSC;9;9;"+$executionContext.SessionState.Path.CurrentLocation+"&ST;" + $executionContext.SessionState.Path.CurrentLocation } -ForegroundColor DarkYellow -BackgroundColor Black -ElevatedBackgroundColor Gray'),(ScriptBlock ' "`t" '),(ScriptBlock ' New-PromptText { Write-VcsStatus } -ForegroundColor DarkYellow -BackgroundColor Black -ElevatedBackgroundColor Gray'),(ScriptBlock ' "`n" '),(ScriptBlock ' New-PromptText { ">" * ($NestedPromptLevel + 1) } -ForegroundColor Blue -ElevatedForegroundColor Yellow  -BackgroundColor Black -ElevatedBackgroundColor Gray'))
    Colors = @((RgbColor 'Cyan'),(RgbColor 'DarkCyan'),(RgbColor 'Gray'),(RgbColor 'DarkGray'),(RgbColor 'Gray'))
  }
  EscapeSequences = @{
    Esc = '๏ฟฝ['
    Store = '๏ฟฝ[s'
    Recall = '๏ฟฝ[u'
    Clear = '๏ฟฝ[0m'
    OSC = '๏ฟฝ]'
    ST = '๏ฟฝ\'
  }
  ExtendedCharacters = @{
    ColorSeparator = '๎‚ฐ'
    ReverseColorSeparator = '๎‚ฒ'
    Separator = '๎‚ฑ'
    ReverseSeparator = '๎‚ณ'
    Branch = '๎‚ '
    Lock = '๎‚ข'
    Gear = 'โ›ฏ'
    Power = 'โšก'
  }
}

I can work around this by forcing the use of PowerLine 3.3.0 in my profile.ps1:

Import-Module PowerLine -RequiredVersion 3.3.0

This is under PowerShell 7.1.4, installed as a .NET Global Tool.

PowerLine seems to install correctly, but fails when enabled in profile.ps1

The installation of PowerLine seemed to succeed inside powershell, but when I added

#requires -module PowerLine
using module PowerLine

$PowerLinePrompt = @(
        @{ bg = "Cyan";     fg = "White"; text = { $MyInvocation.HistoryId } }
        @{ bg = "DarkBlue"; fg = "White"; text = { $pwd } }
    )

Set-PowerLinePrompt -PowerLineFont

To my Microsoft.PowerShell_profile.ps1 the startup of the Powershell window ended in this:

The property 'UseAnsiEscapes' cannot be found on this object. Verify that the property exists and can be set.
t C:\Program Files\WindowsPowerShell\Modules\PowerLine\2.3.1\PowerLine.psm1:420 char:5
     $global:PowerLinePrompt.UseAnsiEscapes = $UseAnsiEscapes
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
   + FullyQualifiedErrorId : PropertyAssignmentException

he property 'RestoreVirtualTerminal' cannot be found on this object. Verify that the property exists and can be set.
t C:\Program Files\WindowsPowerShell\Modules\PowerLine\2.3.1\PowerLine.psm1:421 char:5
     $global:PowerLinePrompt.RestoreVirtualTerminal = $RestoreVirtualT ...
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
   + FullyQualifiedErrorId : PropertyAssignmentException

Does anyone has some ideas on this?

Error when invoking Set-PowerLinePrompt

I'm getting an error when invoking Set-PowerLinePrompt in profile.ps1

Import-Metadata : At C:\Users\lukas\AppData\Roaming\powershell\HuddledMasses.org\PowerLine\Configuration.psd1:21 char:102
+ ... .CurrentLocation '),(ScriptBlock ' '>' * ($nestedPromptLevel + 1) '))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Redirection is not allowed in restricted language mode or a Data section.
At C:\Program Files\WindowsPowerShell\Modules\Configuration\1.3.0\Configuration.psm1:417 char:21
+ ... Import-Metadata $EnterprisePath -ErrorAction Ignore -Orde ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (@{
EscapeSequ... 'Gray'))
}
}:ScriptBlock) [Import-Metadata], ParseException
+ FullyQualifiedErrorId : Metadata Error,Import-Metadata

My PowerShell:

PSVersion 5.1.17134.1
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.1
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

I'm new to PowerShell, so it might be after all a problem on my side, just not sure what kind of.

Get-SegmentedPath variably handles alternative PSDrives with bugs

The function Get-SegmentedPath sometimes does not correctly handle alternative PSDrives other than the default "C:" drive on Windows. The author of this issue is uncertain of the exact conditions that lead to correct handling or not.

Examples

The environment drive

Steps to reproduce

Set-Location 'Env:'
[string] (PowerLine\Get-SegmentedPath)

Expected behavior

Env:

Actual behavior

Custom filesystem drives

Steps to reproduce

New-PSDrive -Name 'FooBar' -PSProvider 'FileSystem' -Root $Env:TEMP
Set-Location 'FooBar:'
[string] (PowerLine\Get-SegmentedPath)

Expected behavior

FooBar:

Actual Behavior

Temp

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.0
PSEdition                      Core
GitCommitId                    6.2.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0โ€ฆ}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Enh request - function to get ~ relative path

When I'm in my home dir I want my paths to be shortened e.g.:

~\Documents\WindowsPowerShell

I could see a number of Path oriented commands like this including collapsing paths to a form like C:\Git\...\src\PowerShellEditorServices.Protocol\DebugAdapter to make a path fit within a certain number of characters.

Using git's pager by any means breaks colored output.

git commands that invoke the pager (for paged output, e.g. fetch --all, diff, etc) have the side effect of breaking the color outputting of the prompt.

image

This also effects all embedded terminales (Visual Studio, Visual Studio Code)
image

This does not affect ConEmu:
image

Configuration Used

#requires -module PowerLine
using module PowerLine

$PowerLinePrompt = @(
        @{ bg = "Cyan";     fg = "White"; text = { $MyInvocation.HistoryId } }
        @{ bg = "DarkBlue"; fg = "White"; text = { $pwd } }
    )

Set-PowerLinePrompt -PowerLineFont

OS

Edition      Windows 10 Pro
Version      1703
OS Build     15063.138

This is very strange, especially since the Windows 10 Creator's Update added a ton of support and functionality to the console.

There's a possiblity that git's msys less.exe is outputting something bad that is then breaking all further output?

List available blocks + how to add them.

Immediately after installation instructions have a really short section listing the blocks you can add to a prompt and an example showing how to do it.

The rest of the info about block setup + how it works is useful, but casual devs just want to dive in and choose some they like.

"Exception thrown from prompt block" even when the exception is handled within the block

Run the following to test this issue:

$Prompt.Add( { try{throw "error"}catch{} } )

The result is a WARNING:

WARNING: Exception thrown from prompt block. Check $PromptErrors. To suppress this message, Set-PowerLine -HideError
WARNING: Exception in PowerLinePrompt

$PromptErrors contains:

Name  : 3 { try{throw "error"}catch{} }
Value : {System.Management.Automation.RuntimeException}
  • PowerLine Module Version 3.4.0
  • Pansies Module Version 2.3.1
    Tested on:
  • Arch Linux with PowerShell Core 7.1.5
  • Windows 10 with PowerShell 5.1.19041.1237

Expected behavior:

  • When an exception is captured, the error should not be displayed.

PowerLine fails to import in a PSRemote session

This might also be a problem with Pansies.

Import-Metadata : Exception calling "InvokeReturnAsIs" with "1" argument(s): "Cannot convert value "Cyan" to type "PoshCode.Pansies.RgbColor". Error: "GetConsoleScreenBufferInfoEx->WinError:
#6""
At C:\Program Files\WindowsPowerShell\Modules\Configuration\1.3.0\Configuration.psm1:417 char:21
+ ...             Import-Metadata $EnterprisePath -ErrorAction Ignore -Orde ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Metadata], MethodInvocationException
    + FullyQualifiedErrorId : RuntimeException,Import-Metadata

Cannot convert the "System.Object[]" value of type "System.Object[]" to type "System.Collections.Generic.List`1[PoshCode.Pansies.RgbColor]".
At C:\Program Files\WindowsPowerShell\Modules\PowerLine\3.0.3\PowerLine.psm1:45 char:13
+             "Cyan","DarkCyan","Gray","DarkGray","Gray"
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [], RuntimeException
    + FullyQualifiedErrorId : ConvertToFinalInvalidCastException

Exception calling "ResetConsolePalette" with "0" argument(s): "GetConsoleScreenBufferInfoEx->WinError: #6"
At C:\Program Files\WindowsPowerShell\Modules\PowerLine\3.0.3\PowerLine.psm1:787 char:5
+     [PoshCode.Pansies.RgbColor]::ResetConsolePalette()
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : Exception

Enter-PSSession : Running startup script threw an error: Exception calling "ResetConsolePalette" with "0" argument(s): "GetConsoleScreenBufferInfoEx->WinError: #6".
At line:1 char:1
+ Enter-PSSession jarcher -ConfigurationName Profile
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Enter-PSSession], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation

Where is the prompt settings stored?

Back when I was using PowerShell on Windows I had customized the prompts a lot with PowerLine. I moved on to PowerShell Core about 5 months ago. I just decided to install the modules for PowerLine but when I import the module the old prompt I had back in PowerShell for Windows shows up.

I can't figure out how to get rid of the old prompt.

Doesn't work in Powershell Core

I receive the following error on Arch Linux with PowerShell 7.0.0-rc.3:

WARNING: Exception in PowerLinePrompt
Cannot convert value "System.Collections.Hashtable" to type "PoshCode.Pansies.Text". Error: "Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')"

Error calling Set-PowerlinePrompt after update to 2.3.1

So I updated to 2.3.1, and now my profile won't load. I stripped it down To the bare minimum, and we get

using module PowerLine
using namespace PowerLine

Set-StrictMode -Version Latest
Set-PSDebug -Strict -Trace 0
$PowerLinePrompt = @(
@{ bg = "Cyan"; fg = "White"; text = { $MyInvocation.HistoryId } }
@{ bg = "DarkBlue"; fg = "White"; text = { $pwd } }
)

if ($Env:ConEmuANSI -or $Host.UI.SupportsVirtualTerminal) {
Set-PowerLinePrompt -CurrentDirectory -PowerLineFont -Title { "PowerShell - {0} ({1})" -f (Convert-Path $pwd),$pwd.Provider.Name }
}

and I recieve the error:

The property 'Title' cannot be found on this object. Verify that the property exists and can be set.
At C:\Program Files\WindowsPowerShell\Modules\PowerLine\2.3.1\PowerLine.psm1:414 char:9

  •     $global:PowerLinePrompt.Title = $Title
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyAssignmentException`

The property 'SetCurrentDirectory' cannot be found on this object. Verify that the property exists and can be set.
At C:\Program Files\WindowsPowerShell\Modules\PowerLine\2.3.1\PowerLine.psm1:417 char:9

  •     $global:PowerLinePrompt.SetCurrentDirectory = $CurrentDirecto ...
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyAssignmentException`

The property 'UseAnsiEscapes' cannot be found on this object. Verify that the property exists and can be set.
At C:\Program Files\WindowsPowerShell\Modules\PowerLine\2.3.1\PowerLine.psm1:420 char:5

  • $global:PowerLinePrompt.UseAnsiEscapes = $UseAnsiEscapes
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyAssignmentException`

The property 'RestoreVirtualTerminal' cannot be found on this object. Verify that the property exists and can be set. At C:\Program Files\WindowsPowerShell\Modules\PowerLine\2.3.1\PowerLine.psm1:421 char:5

  • $global:PowerLinePrompt.RestoreVirtualTerminal = $RestoreVirtualT ...
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : PropertyAssignmentException`

PS>get-module pansies|select Name, Version, ModuleBase

Name Version ModuleBase


Pansies 1.0.0 C:\Program Files\WindowsPowerShell\Modules\Pansies\1.0.0 `

PS>get-module powerline|select Name, Version, ModuleBase

Name Version ModuleBase


PowerLine 2.3.1 C:\Program Files\WindowsPowerShell\Modules\PowerLine\2.3.1 `

PSVersionTable:

PS>$PSVersionTable

Name Value


PSVersion 5.1.14409.1005
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14409.1005
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Running on Windows7 sp1 x64.

I think I'm missing something simple.

Error running Install-Module PowerLine

Nowhere in the documentation is this gotcha mentioned. Is this on purpose? Can you explain why it would override Write-Host?

PS C:\source\> install-module PowerLine

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): a
PackageManagement\Install-Package : The following commands are already available on this system:'Write-Host'. This module 'Pansies' may override the existing commands. If you still want to install this module 'Pansies', use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.7\PSModule.psm1:9491 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
PS C:\source> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17134.228
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.228
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module loading performance is slow

When I enable PowerLine as part of my profile.ps1 PowerShell reports the following message:

Loading personal and system profiles took 1608ms

Loading times vary between 1600 and 1800ms.

Is there any way to optimize the loading time?

here is my profile.ps1 file:

#requires -module @{ModuleName='PowerLine';ModuleVersion='3.0.3'}, @{ModuleName='PSGit'; ModuleVersion='2.0.4'}

$global:prompt = @(
    { "&Gear;" * $NestedPromptLevel }
    { if($pushd = (Get-Location -Stack).count) { "$([char]187)" + $pushd } }
    { $pwd.Drive.Name }
    { Split-Path $pwd -leaf }
    { Get-GitStatusPowerline }
)

Set-PowerLinePrompt -SetCurrentDirectory -PowerLineFont -Title {
    -join @(if (Test-Elevation) { "Administrator: " }
        if ($IsCoreCLR) { "pwsh - " } else { "Windows PowerShell - "}
        Convert-Path $pwd)
} -Colors "DarkBlue", "White", "Cyan", "White", "DarkBlue", "DarkCyan"

Regards,

Stephan

Error With New PowerShell 7.1 preview 2 - Get-Date Usage Needs Full Parameter Name

The new PowerShell 7.1 preview 2 adds a new parameter to "Get-Date" called "-FromUnixTime":

Add -FromUnixTime to Get-Date to allow Unix time input (#12179) (Thanks @jackdcasey!)

The following error is now produced upon importing the module:

WARNING: Exception thrown from prompt block. Check $PromptErrors. To suppress this message, Set-PowerLine -HideError
Parameter cannot be processed because the parameter name 'f' is ambiguous. Possible matches include: -Format -FromUnixTime.

This appears due to PowerLine using 'Get-Date -f "T"'. It would appear that PowerLine is using it as an abbreviated form of the "-Format" Parameter of "Get-Date", rather than the "-f" Format Operator. PowerShell also seems to parse it that way, as using the "-f" Format Operator yields both date and time in PSH v5.1, 7.0, and 7.1p2:

PS B:\PSH7.1> (Get-Date) -F "T"
04/25/2020 16:16:14
PS B:\PSH7.1> Get-Date -Format "T"
16:16:59

It looks like these source scripts need changes to replace the "-f" with "-Format":

Source\Examples\Sample.ps1: { Get-Date -f "T" }
Source\Examples\SampleForConsolas.ps1: { Get-Date -f "T" }
Source\Public\Set-PowerLinePrompt.ps1: { Get-Date -f "T" }

Please let me know if you have any questions. Thank you.

Install failed

Hi,
I was attempting to install under Windows 10, and hit an error (it's certainly possible that my dev box at work is being blocked from something needed to make this work.

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its
InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y
WARNING: Source Location 'https://www.powershellgallery.com/api/v2/package/Configuration/1.3.1' is not valid.
PackageManagement\Install-Package : Package 'Configuration' failed to download.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (C:\Users\A64217...iguration.nupkg:String) [Install-Package], Excep
   tion
    + FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
   kage

S

Set the background to "default" instead of BackgroundColor

As of Windows 10 build 18298, the new โ€œTerminalโ€ settings allow setting default ForegroundColor and BackgroundColor values which are separate from the 16 color "ConsoleColor" palette.

PowerLine doesn't use the ANSI/VT escape sequence for default as the default background, but instead specified $Host.UI.RawUI.BackgroundColor -- which no longer matches the actual background color if the user sets the terminal settings.

Error with separator

Hi
I would like try this module but i have some trouble, I Install all module PANSIES, Powerline in scope CurrentUser. I also install all PowerLine font with the powershell file.
I don't why i don't have the same separator like your picture. thx for your help.
It is the same way in the regular powershell console.

Capture

Git commands causing powerline failure

Every time I run the commands git clone, git pull, or git push my terminal's output get's turned into what look like the underlying character codes.

powershell_powerline_git_failure

I'm using HyperTerm but have verified that this occurs even in regular PowerShell.

powershell_powerline_git_failure_ps

My PowerLine config is just a slightly modified version of the demo in the Readme:

# PowerLine
#requires -Module @{ModuleName="PSGit"; ModuleVersion="2.0.4"}, @{ModuleName="PowerLine"; ModuleVersion="2.0.0"}
using module PowerLine
using namespace PowerLine

$PowerLinePrompt = 0,
(
  @(
    @{ bg = "Blue";     fg = "White"; text = { $env:USERNAME } }
    @{ bg = "Cyan";     fg = "White"; text = { $PWD } }
    @{ bg = "Cyan";     fg = "White"; text = { if($pushd = (Get-Location -Stack).count) { "$([char]187)" + $pushd } } }
    # PSGit is still in early stages, but it has PowerLine support
    @{ text = { Get-GitStatusPowerline } }
  ),
  @(
    @{ text = { New-PowerLineBlock (Get-Elapsed) -ErrorBackgroundColor DarkRed -ErrorForegroundColor White -ForegroundColor Black -BackgroundColor DarkGray } }
    @{ bg = "Gray";     fg = "Black"; text = { Get-Date -f "T" } }
  )
),
@(
  @{ text = { New-PowerLineBlock ("PS") -ErrorBackgroundColor DarkRed -ErrorForegroundColor White -ForegroundColor White -BackgroundColor Green } }
)

Set-PowerLinePrompt -CurrentDirectory -PowerlineFont:(!$SafeCharacters) -Title { "PowerShell - {0} ({1})" -f (Convert-Path $pwd),  $pwd.Provider.Name }

# As a bonus, here are the settings I use for my PSGit prompt:
Set-GitPromptSettings -SeparatorText '' -BeforeText '' -BeforeChangesText '' -AfterChangesText '' -AfterNoChangesText '' `
                      -BranchText "$([PowerLine.Prompt]::Branch) " -BranchForeground White -BranchBackground Cyan `
                      -BehindByText 'โ–ผ' -BehindByForeground White -BehindByBackground DarkCyan `
                      -AheadByText 'โ–ฒ' -AheadByForeground White -AheadByBackground DarkCyan `
                      -StagedChangesForeground White -StagedChangesBackground DarkBlue `
                      -UnStagedChangesForeground White -UnStagedChangesBackground Blue

I'm using the font Fira Code to provide PowerLine support and ligatures.

Support for no background colour

Hi, I've recently managed to get this set up and I have been enjoying the customization features. However there is one issue I find with my specific set up.

I am using the new Windows Terminal and if I switch off 'useAcrylic' I can set the background colour of the my powerline to the colour of the terminal and it looks great. However I like to use Terminal with the acrylic setting enabled, however in this case I can now see the background colour:

image

I found that it is also not possible to remove the colour from the configuration.psd1 to leave only the text. Is this something that is possible to support?

Can't install with Pansies 1.4.0-beta03

VERBOSE: For publisher validation, using the previously-installed module 'Pansies' with version '1.4.0' under 'C:\Program
Files\WindowsPowerShell\Modules\Pansies\1.4.0' with publisher name 'CN=Joel H. Bennett, O=Joel H. Bennett, L=West Henrietta, S=New York,
C=US' from root certificate authority 'CN=DigiCert Assured ID Root CA, OU=www.digicert.com, O=DigiCert Inc, C=US'. Is this module signed by
Microsoft: 'False'.
PackageManagement\Install-Package : The version '1.2.1' of the module 'Pansies' being installed is not catalog signed. Ensure that the vers
ion '1.2.1' of the module 'Pansies' has the catalog file 'Pansies.cat' and signed with the same publisher 'CN=Joel H. Bennett, O=Joel H. Be
nnett, L=West Henrietta, S=New York, C=US' as the previously-installed module 'Pansies' with version '1.4.0' under the directory 'C:\Progra
m Files\WindowsPowerShell\Modules\Pansies\1.4.0'. If you still want to install or update, use -SkipPublisherCheck parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.2\PSModule.psm1:9683 char:34

  • ... talledPackages = PackageManagement\Install-Package @PSBoundParameters
  •                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    • FullyQualifiedErrorId : ModuleIsNotCatalogSigned,Validate-ModuleAuthenticodeSignature,Microsoft.PowerShell.PackageManagement.Cmdlets
      .InstallPackage

Conditional block colors

Is there a way to conditionally set BackgroundColor and ForegroundColor for blocks? I am trying to setup different colors based on git changes, same as Fish shell does it.
image

Question regarding setup

Hi there!

I just installed and have been going over the readme and had a question.

Currently on my mac/linux machines, I have my powerline prompt setup to this.

screen shot 2017-01-04 at 1 30 40 pm

Where instead of just printing out the PWD, it prints the whole path from $HOME. But if the path is more than 3 directories deep, it shortens is with the ....

Would such a setup be possible?

Special characters is not shown in powershell.

I install PowerLine like they saying in the README. First install the Pansies module and after install the PowerLine Module and finally import the PowerLine module. But, when I import the PowerLine module I get this.

powershell

I've too try out this in ConEmu

Module trying to overwrite 'Write-Host'

This error after 'Install-Module PowerLine' and then agreeing to an 'Untrusted repository'.

PackageManagement\Install-Package : The following commands are already available on this system:'Write-Host'. This
module 'Pansies' may override the existing commands. If you still want to install this module 'Pansies', use
-AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21

  • ... $null = PackageManagement\Install-Package @PSBoundParameters
  •                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Packag
      e], Exception
    • FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.
      PackageManagement.Cmdlets.InstallPackage

Enh req - API tweaks

I think the Prompt and Line types should use aggregation rather than inheritance. That will make the Intellisense completion list way more relevant and the object model becomes more intuitive IMO:

$PowerLinePrompt.Lines[0].Blocks[0]
$PowerLinePrompt.Lines[1].Blocks.Insert(0, ....)

Also, rather than rely on position relative to the [BlockCache]::Column object why not either have a Block property Alignment e.g.:

@{ bg = "DarkRed";  fg = "White"; align = "Right"; text = $Env:USERNAME + "@" + $Env:COMPUTERNAME}

I think that would make the alignment feature be a bit more discoverable. Another option would be to have two collections in Line - BlocksRightAligned and BlocksLeftAligned.

Set-GitPromptSettings' is not recognized

Set-GitPromptSettings : The term 'Set-GitPromptSettings' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:25 char:1
+ Set-GitPromptSettings -SeparatorText '' -BeforeText '' -BeforeChanges ...
+ ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Set-GitPromptSettings:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Inconsistent color selection in 3.0

The prompt section colors change when using -ErrorBackground.

 "`t"
New-PromptText {Get-ElapsedHumanized}  -ErrorBackground DarkRed
 "`n"
New-PromptText {$SessionTitleName}  -ElevatedForegroundColor Yellow
 Get-SegmentedPath
 "`n"
 'PS ' + '>' * ($nestedPromptLevel + 1)

hyper_2017-10-26_13-54-27

Name      Version
----      -------
PowerLine 3.0.3

Name                           Value
----                           -----
PSVersion                      5.1.15063.674
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.674

Spacing issues after input

On Windows 10 (Build 15063, PS version 5.1.15063.0) there is some spacing issues, when the line is created there is a space before each part, and after typing anything the spaces go to the front of the line. Here are some screenshots.

Spaces before sections:
2017-04-10 4

Spaces after input:
2017-04-10 3

The number of spaces seems to be mantained.
2017-04-10 5

Access to the path is denied when installing to -Scope CurrentUser

Thanks for the projects, like your documentation and how you make it flexible.

Env

I'm on Linux Mint.

PS>$PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.1.1
PSEdition                      Core
GitCommitId                    6.1.1
OS                             Linux 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Steps to reproduce

PS> Install-Module PowerLine -Scope CurrentUser
PS> Import-Module PowerLine 

Error

P> Set-PowerLinePrompt -SetCurrentDirectory -RestoreVirtualTerminal -Newline -Timestamp -Colors "#00DDFF","#0066FF"
WARNING: The Enterprise path /etc/xdg/xdg-cinnamon/powershell cannot be found
New-Item : Access to the path '/etc/xdg/xdg-cinnamon/powershell/HuddledMasses.org' is denied.
At /home/ed8/.local/share/powershell/Modules/Configuration/1.3.1/Configuration.psm1:232 char:21
+             $null = New-Item $PathRoot -Type Directory -Force
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo          : PermissionDenied: (/etc/xdg/xdg-ci...ddledMasses.org:String) [New-Item], UnauthorizedAccessException
+FullyQualifiedErrorId : CreateDirectoryUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommand

New-Item : Access to the path '/etc/xdg/xdg-cinnamon/powershell/HuddledMasses.org/PowerLine' is denied.
At /home/ed8/.local/share/powershell/Modules/Configuration/1.3.1/Configuration.psm1:232 char:21
+            $null = New-Item $PathRoot -Type Directory -Force
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : PermissionDenied: (/etc/xdg/xdg-ci...s.org/PowerLine:String) [New-Item], UnauthorizedAccessException
+ FullyQualifiedErrorId : CreateDirectoryUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommand

WARNING: The Enterprise path /etc/xdg/xdg-cinnamon/powershell cannot be found
New-Item : Access to the path '/etc/xdg/xdg-cinnamon/powershell/HuddledMasses.org' is denied.
At /home/ed8/.local/share/powershell/Modules/Configuration/1.3.1/Configuration.psm1:232 char:21
+             $null = New-Item $PathRoot -Type Directory -Force
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo          : PermissionDenied: (/etc/xdg/xdg-ci...ddledMasses.org:String) [New-Item], UnauthorizedAccessException
+FullyQualifiedErrorId : CreateDirectoryUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommand

New-Item : Access to the path '/etc/xdg/xdg-cinnamon/powershell/HuddledMasses.org/PowerLine' is denied.
At /home/ed8/.local/share/powershell/Modules/Configuration/1.3.1/Configuration.psm1:232 char:21
+             $null = New-Item $PathRoot -Type Directory -Force
+                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : PermissionDenied: (/etc/xdg/xdg-ci...s.org/PowerLine:String) [New-Item], UnauthorizedAccessException
+FullyQualifiedErrorId : CreateDirectoryUnauthorizedAccessError,Microsoft.PowerShell.Commands.NewItemCommand

Set-Content : Could not find a part of the path '/etc/xdg/xdg-cinnamon/powershell/HuddledMasses.org/PowerLine/Configuration.psd1'.
At /home/ed8/.local/share/powershell/Modules/Configuration/1.3.1/Metadata.psm1:520 char:9
+         Set-Content -Encoding UTF8 -Path $Path -Value ((@($CommentHea ...
+        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+CategoryInfo          : ObjectNotFound: (/etc/xdg/xdg-ci...figuration.psd1:String) [Set-Content], DirectoryNotFoundException
+FullyQualifiedErrorId : GetContentWriterDirectoryNotFoundError,Microsoft.PowerShell.Commands.SetContentCommand

Install fails without -AllowClobber

The installation instructions imply that Pansies is optional:

NOTE: If you don't have my PANSIES module for ANSI Escape Sequences, you may want to install that separately

However, I'm unable to install the PowerLine module because it appears to want to pull in the Pansies module, yet I don't want to clobber Write-Host:

C:\WINDOWS\system32> Install-Module PowerLine                                                                          
PackageManagement\Install-Package : The following commands are already available on this system:'Write-Host'. This
module 'Pansies' may override the existing commands. If you still want to install this module 'Pansies', use
-AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package],
   Exception
    + FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.Pack
   ageManagement.Cmdlets.InstallPackage

Question Marks in place of characters in ConEmu

Hello,

I just setup PowerLine in my console with the example setup in the readme. Currently it seems to be working correctly but I am getting question marks in the console instead of characters. Seems like an ASCII issue and was wondering if I just missed something to get them to show.

image

Remove color for path

Hi,
is there a way to remove the colorization of the current path?

Current config:
Set-PowerLinePrompt -SetCurrentDirectory
-RestoreVirtualTerminal -Title { $title = "PowerShell {0} - {1} ({2}) - PID: {3}" -f $PSVersionTable.PSVersion.ToString(),(Convert-Path $pwd), $pwd.Provider.Name,$PID if (Test-Elevation) { "Elevated - $title" } else { $title } }
-Prompt @( { "$($MyInvocation.HistoryId)" },
{ "t" }, { Get-Elapsed }, { Get-Date -f "T" }, { "n" },
{ "$($pwd)" }) -FullColor: $false
-Save`

Get-Elapsed -Format doesn't work

The parameter/arg get passed to Get-History because of the @PSBoundParameters and Get-History barfs:

PS>Get-Elapsed -Format '{0:h\:mm\:ss\.fff}'
Get-History : A parameter cannot be found that matches parameter name 'Format'.
At C:\Users\Keith\Documents\WindowsPowerShell\Modules\PowerLine\1.0.0\PowerLine.psm1:25 char:40
+    $LastCommand = Get-History -Count 1 @PSBoundParameters
+                                        ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-History], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetHistoryCommand

Set-PSBreakpoint in profile breaks set-powerlineprompt

I have this statement in my profile to set a variable date string.
Set-PSBreakpoint -Variable Dt -Mode Read -Action {$Global:Dt=((get-date -f o).replace(':','-')) -replace ".{6}$"; $Global:Dt}

This causes the first command to cause the prompt to be reset to just PS.
In addition all commands including dir do not produce any output to the PS console.
Set-PowerLinePrompt -SetCurrentDirectory -RestoreVirtualTerminal -Newline -Timestamp -Colors "#00DDFF","#0066FF"

PowerLine fails to import saved prompt including a single-quoted string

When I run this interactively it works, however when I export it and reopen PowerShell and reimport PowerLine it throws at line 6.

Looking at it more closely it looks like it's some kind of bug in the Configuration module maybe? Or maybe just in the export command. Let me know if you'd rather track this on Configuration.

https://gist.github.com/Chirishman/ad7ab9492f9972d77536e89fb1f02053

Error:

Import-Metadata : Exception calling "Create" with "1" argument(s): "At line:1 char:63
+ New-PromptText -Fg White -Bg 20 (((Get-SegmentedPath) -replace
+                                                               ~
You must provide a value expression following the '-replace' operator.
At line:1 char:63
+ New-PromptText -Fg White -Bg 20 (((Get-SegmentedPath) -replace
+                                                               ~
Missing closing ')' in expression."
At C:\Program Files\WindowsPowerShell\Modules\Configuration\1.3.1\Configuration.psm1:417 char:21
+ ...             Import-Metadata $EnterprisePath -ErrorAction Ignore -Orde ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Metadata], MethodInvocationException
    + FullyQualifiedErrorId : ParseException,Import-Metadata

Errors while using with PowerShell Core on Mac

Ran into the problems below while trying this out on my Mac with the latest version of PowerShell:

PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

cdLoading personal and system profiles took 827ms.

PS /Users/gene.liverman> $PSVersionTable.PSVersion

Major Minor Patch Label
----- ----- ----- -----
    6     0     0 beta

PS /Users/gene.liverman> Install-Module PowerLine -Scope CurrentUser

Untrusted repository 
You are installing the modules from an untrusted repository. If you trust this repository,
change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you
sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y

PS /Users/gene.liverman> Get-Module -ListAvailable PowerLine


    Directory: /Users/gene.liverman/.local/share/powershell/Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.3.1      PowerLine                           {Set-PowerLinePrompt, Add-PowerLineBlock, New-TextFactory, Get-Elapsed...}


PS /Users/gene.liverman> using module PowerLine
Exception calling "EnableVirtualTerminalProcessing" with "0" argument(s): "The type initializer for 'PoshCode.Pansies.Console.WindowsHelper' threw an exception."
    + CategoryInfo          : InvalidOperation: (/Users/gene.liv.../PowerLine.psd1:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : TypeInitializationException,Microsoft.PowerShell.Commands.ImportModuleCommand

PS /Users/gene.liverman> $PowerLinePrompt = @(
>>         @{ bg = "Cyan";     fg = "White"; text = { $MyInvocation.HistoryId } }
>>         @{ bg = "DarkBlue"; fg = "White"; text = { $pwd } }
>>     )

PS /Users/gene.liverman> Set-PowerLinePrompt -PowerLineFont 
The property 'UseAnsiEscapes' cannot be found on this object. Verify that the property exists and can be set.
At /Users/gene.liverman/.local/share/powershell/Modules/PowerLine/2.3.1/PowerLine.psm1:420 char:5
+     $global:PowerLinePrompt.UseAnsiEscapes = $UseAnsiEscapes
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

The property 'RestoreVirtualTerminal' cannot be found on this object. Verify that the property exists and can be set.
At /Users/gene.liverman/.local/share/powershell/Modules/PowerLine/2.3.1/PowerLine.psm1:421 char:5
+     $global:PowerLinePrompt.RestoreVirtualTerminal = $RestoreVirtualT ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyAssignmentException

PS>

Improve instructions

The current instructions do not make it obvious which commands I am supposed to perform vs what's going on in the background.

For instance, am I supposed to add this:

function prompt {
    -join $prompt.Invoke()
}

or

[System.Collections.Generic.List[ScriptBlock]]$Prompt = @(
    { "PS " }
    { $executionContext.SessionState.Path.CurrentLocation }
    { '>' * ($nestedPromptLevel + 1) }
)

or as per Sample.ps1 (which doesn;t run successfully)

$global:PowerLinePrompt = 1,
    # two lines
    @(
        # on the first line, two columns -- the first one is null (empty), the second is right-justified
        $null,
        @(
            @{ text = { New-PowerLineBlock (Get-Elapsed) -ErrorBackgroundColor DarkRed -ErrorForegroundColor White -ForegroundColor Black -BackgroundColor DarkGray } }
            @{ bg = "Gray";     fg = "Black"; text = { Get-Date -f "T" } }
        )
    ),
    (
        @{ bg = "Blue";     fg = "White"; text = { $MyInvocation.HistoryId } },
        @{ bg = "Cyan";     fg = "White"; text = { [PowerLine.Prompt]::Gear * $NestedPromptLevel } },
        @{ bg = "Cyan";     fg = "White"; text = { if($pushd = (Get-Location -Stack).count) { "$([char]187)" + $pushd } } },
        @{ bg = "DarkBlue"; fg = "White"; text = { $pwd.Drive.Name } },
        @{ bg = "DarkBlue"; fg = "White"; text = { Split-Path $pwd -leaf } },
        # This requires my PoshCode/PSGit module and the use of the SamplePSGitConfiguration -- remove the last LeftCap in that.
        @{ bg = "DarkCyan";               text = { Get-GitStatusPowerline } }
    )

It would help a lot if there were some simple tutorials/walkthroughs.

Needed to install prerelease Pansies

Just wanted to try that module, so I went with

Install-Module PANSIES -AllowClobber
Install-Module PowerLine
Import-Module PowerLine

which gives me

WARNING: Exception in PowerLinePrompt
Unable to find type [PoshCode.Pansies.Console.WindowsHelper].

What solved this problem is installing latest beta version - 1.4.0-beta03

Install-Module Pansies -Scope Currentuser -AllowPrerelease -AllowClobber -Force

I would find it helpful to add that to doc or somehow clarify how to get it working with 1.3.0 (which is installed by default).

Run this every time ?

Hi,
Any idea how I can get this to be my prompt every time I open the prompt ?

Cheers
S

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.