Welcome to the Chocolatey Community Package Repository! The packages found in this section of the site are provided, maintained, and moderated by the community.
Moderation
Every version of each package undergoes a rigorous moderation process before it goes live that typically includes:
- Security, consistency, and quality checking
- Installation testing
- Virus checking through VirusTotal
- Human moderators who give final review and sign off
More detail at Security and Moderation.
Organizational Use
If you are an organization using Chocolatey, we want your experience to be fully reliable. Due to the nature of this publicly offered repository, reliability cannot be guaranteed. Packages offered here are subject to distribution rights, which means they may need to reach out further to the internet to the official locations to download files at runtime.
Fortunately, distribution rights do not apply for internal use. With any edition of Chocolatey (including the free open source edition), you can host your own packages and cache or internalize existing community packages.
Disclaimer
Your use of the packages on this site means you understand they are not supported or guaranteed in any way. Learn more...
- Passing
- Failing
- Pending
- Unknown / Exempted

Downloads:
7,209
Downloads of v 2.0.496:
882
Last Update:
10 Jan 2021
Package Maintainer(s):
Software Author(s):
- JanDeDobbeleer
Tags:
powershell oh-my-posh posh conemu- Software Specific:
- Software Site
- Software Source
- Software License
- Software Docs
- Software Issues
- Package Specific:
- Package Source
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download

Oh-My-Posh
- Software Specific:
- Software Site
- Software Source
- Software License
- Software Docs
- Software Issues
- Package Specific:
- Package Source
- Package outdated?
- Package broken?
- Contact Maintainers
- Contact Site Admins
- Software Vendor?
- Report Abuse
- Download
Downloads:
7,209
Downloads of v 2.0.496:
882
Maintainer(s):
Software Author(s):
- JanDeDobbeleer
Edit Package
To edit the metadata for a package, please upload an updated version of the package.
Chocolatey's Community Package Repository currently does not allow updating package metadata on the website. This helps ensure that the package itself (and the source used to build the package) remains the one true source of package metadata.
This does require that you increment the package version.
All Checks are Passing
2 Passing Test
To install Oh-My-Posh, run the following command from the command line or from PowerShell:
To upgrade Oh-My-Posh, run the following command from the command line or from PowerShell:
To uninstall Oh-My-Posh, run the following command from the command line or from PowerShell:
NOTE: This applies to both open source and commercial editions of Chocolatey.
1. Ensure you are set for organizational deployment
Please see the organizational deployment guide
2. Get the package into your environment-
Open Source or Commercial:
- Proxy Repository - Create a proxy nuget repository on Nexus, Artifactory Pro, or a proxy Chocolatey repository on ProGet. Point your upstream to https://chocolatey.org/api/v2. Packages cache on first access automatically. Make sure your choco clients are using your proxy repository as a source and NOT the default community repository. See source command for more information.
- You can also just download the package and push it to a repository Download
-
Open Source
- Download the Package Download
- Follow manual internalization instructions
-
Package Internalizer (C4B)
- Run
choco download oh-my-posh --internalize --source=https://chocolatey.org/api/v2
(additional options) - Run
choco push --source="'http://internal/odata/repo'"
for package and dependencies - Automate package internalization
- Run
3. Enter your internal repository url
(this should look similar to https://chocolatey.org/api/v2)
4. Choose your deployment method:
choco upgrade oh-my-posh -y --source="'STEP 3 URL'" [other options]
See options you can pass to upgrade.
See best practices for scripting.
Add this to a PowerShell script or use a Batch script with tools and in places where you are calling directly to Chocolatey. If you are integrating, keep in mind enhanced exit codes.
If you do use a PowerShell script, use the following to ensure bad exit codes are shown as failures:
choco upgrade oh-my-posh -y --source="'STEP 3 URL'"
$exitCode = $LASTEXITCODE
Write-Verbose "Exit code was $exitCode"
$validExitCodes = @(0, 1605, 1614, 1641, 3010)
if ($validExitCodes -contains $exitCode) {
Exit 0
}
Exit $exitCode
- name: Ensure oh-my-posh installed
win_chocolatey:
name: oh-my-posh
state: present
version: 2.0.496
source: STEP 3 URL
See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.
Coming early 2020! Central Managment Reporting available now! More information...
chocolatey_package 'oh-my-posh' do
action :install
version '2.0.496'
source 'STEP 3 URL'
end
See docs at https://docs.chef.io/resource_chocolatey_package.html.
Chocolatey::Ensure-Package
(
Name: oh-my-posh,
Version: 2.0.496,
Source: STEP 3 URL
);
Requires Otter Chocolatey Extension. See docs at https://inedo.com/den/otter/chocolatey.
cChocoPackageInstaller oh-my-posh
{
Name = 'oh-my-posh'
Ensure = 'Present'
Version = '2.0.496'
Source = 'STEP 3 URL'
}
Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.
package { 'oh-my-posh':
provider => 'chocolatey',
ensure => '2.0.496',
source => 'STEP 3 URL',
}
Requires Puppet Chocolatey Provider module. See docs at https://forge.puppet.com/puppetlabs/chocolatey.
salt '*' chocolatey.install oh-my-posh version="2.0.496" source="STEP 3 URL"
See docs at https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.chocolatey.html.
5. If applicable - Chocolatey configuration/installation
See infrastructure management matrix for Chocolatey configuration elements and examples.
This package was approved as a trusted package on 10 Jan 2021.
ConEmu based Powershell theme engine.
Package Specific
This package appends the following lines to your Powershell Profile on Install if they are not already there
- 'Import-Module posh-git' - Enables posh-git (a requirement of oh-my-posh)
- 'Import-Module oh-my-posh' - Enables oh-my-posh
On uninstall, this package removes the following lines from your Powershell profile
- 'Import-Module oh-my-posh' - Enables oh-my-posh
- 'Set-Theme someTheme' - Any Themes set are removed from the profile.
Posh-Git is not disabled on uninstall.
Features
- Easy installation
- Awesome prompt themes for PowerShell
- Git status indications (powered by posh-git)
- Failed command indication
- Admin indication
- Current session indications (admin, failed command, user)
- Configurable
- Easily create your own theme
- Separate settings for oh-my-posh and posh-git
- Does not mess with the default Powershell console
Prerequisites
- posh-git (Must be installed manually or via PowershellGallery)
- PSReadLine ā„ 2.0.0-beta1 (installed during installation) if using Powershell 6+
- Ability to run unsigned scripts.
$ErrorActionPreference = 'Stop';
if (! (Get-Module -ListAvailable -Name 'posh-git')) {
Write-Host "Posh-Git was not found in powershell modules."
Write-Host "You may need to install Posh-Git manually or run 'Install-Module posh-git' before installing this package."
}
Remove-Module -Name $env:ChocolateyPackageName -Force -ErrorAction SilentlyContinue
$psModuleSource = Join-Path (Join-Path $env:ChocolateyInstall (Join-Path 'lib' $env:ChocolateyPackageName)) 'tools\module'
$PSModulePaths = $env:PSModulePath -split ';'
if($PSVersionTable.PSVersion.Major -gt 5){
$Script:modulePath = Join-Path -Path $env:ProgramFiles -ChildPath "PowerShell\$($PSVersionTable.PSVersion.Major)\Modules\"
if ($PSModulePaths -notcontains $modulePath) {
Write-Verbose "Adding PSModulePath to PATH"
$newPSModulePath = @($modulePath, $PSModulePaths) -join ';'
[Environment]::SetEnvironmentVariable('PSModulePath', $newPSModulePath, 'Machine')
$env:PSModulePath = $newPSModulePath
}
if (! (Get-Module -ListAvailable -Name 'PSReadLine')) {
Write-Host "Installing PSReadLine prerelease from PowershellGallery"
Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
}
}
else{
$Script:modulePath = Join-Path -Path $env:ProgramFiles -ChildPath 'WindowsPowerShell\Modules\'
if ($PSModulePaths -notcontains $modulePath) {
Write-Verbose "Adding PSModulePath to PATH"
$newPSModulePath = @($modulePath, $PSModulePaths) -join ';'
[Environment]::SetEnvironmentVariable('PSModulePath', $newPSModulePath, 'Machine')
$env:PSModulePath = $newPSModulePath
}
}
Copy-Item -Path $psModuleSource -Destination (Join-Path $Script:modulePath $env:ChocolateyPackageName) -Recurse -Force
# Add to Profile
if ($PROFILE -and (Test-Path $PROFILE)) {
$oldProfile = @(Get-Content $PROFILE)
$newProfile = @()
foreach($line in $oldProfile) {
if($line -like 'Import-Module posh-git') {
$PoshGitInProfile = $true
}
if($line -like 'Import-Module oh-my-posh') {
$OhMyPoshInProfile = $true
}
$newProfile += $line
}
if(-not $PoshGitInProfile){
$newProfile += "Import-Module posh-git`n"
}
if(-not $OhMyPoshInProfile){
$newProfile += "Import-Module oh-my-posh`n"
}
Set-Content -path $profile -value $newProfile -Force
Write-Host "oh-my-posh has been added to your profile. You may wish to append 'Set-Theme paradox' to set a theme"
}
else{
Write-Host "No Powershell Profile was found. You may wish to create a Profile and append 'Import-Module posh-git', 'Import-Module oh-my-posh', and 'Set-Theme paradox' to enable oh-my-posh"
}
Write-Host "You may need to change your Powershell Execution Policy to use $env:ChocolateyPackageName."
if($PSVersionTable.PSVersion.Major -gt 5){
$Script:modulePath = Join-Path -Path $env:ProgramFiles -ChildPath "PowerShell\$($PSVersionTable.PSVersion.Major)\Modules\"
}
else{
$Script:modulePath = Join-Path -Path $env:ProgramFiles -ChildPath 'WindowsPowerShell\Modules\'
}
$Script:modulePath = Join-Path $Script:modulePath $env:ChocolateyPackageName
Remove-Item $Script:modulePath -Recurse -Force
#Remove added lines from Profile
if ($PROFILE -and (Test-Path $PROFILE)) {
$oldProfile = @(Get-Content $PROFILE)
$newProfile = @()
foreach($line in $oldProfile) {
if($line -like 'Import-Module posh-git') {
Write-Host "'Import-Module posh-git' was found in your profile but is not being removed."
}
if($line -like 'Import-Module oh-my-posh') {
continue
}
if($line -like 'Set-Theme*') {
Write-Host "'$line' was setting a theme for your profile but is being removed."
continue
}
$newProfile += $line
}
Set-Content -path $profile -value $newProfile -Force
Write-Host "oh-my-posh has been removed from your Powershell profile."
}
else{
Write-Host "No Powershell Profile was found. You may need to undo changes to your Powershell profile manually."
}
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE report PUBLIC "-//JACOCO//DTD Report 1.1//EN" "report.dtd"><report name="Pester (01/10/2021 06:16:25)"><sessioninfo id="this" start="1610259382116" dump="1610259385849" /><package name="Helpers"><class name="Helpers/PoshGit" sourcefilename="PoshGit.ps1"><method name="Format-BranchName" desc="()" line="7"><counter type="INSTRUCTION" missed="3" covered="0" /><counter type="LINE" missed="3" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-VCSStatus" desc="()" line="14"><counter type="INSTRUCTION" missed="4" covered="0" /><counter type="LINE" missed="4" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-BranchSymbol" desc="()" line="23"><counter type="INSTRUCTION" missed="11" covered="0" /><counter type="LINE" missed="10" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-GitRemoteUrl" desc="()" line="40"><counter type="INSTRUCTION" missed="3" covered="0" /><counter type="LINE" missed="3" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-VcsInfo" desc="()" line="53"><counter type="INSTRUCTION" missed="106" covered="0" /><counter type="LINE" missed="66" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="<script>" desc="()" line="186"><counter type="INSTRUCTION" missed="0" covered="2" /><counter type="LINE" missed="0" covered="2" /><counter type="METHOD" missed="0" covered="1" /></method><counter type="INSTRUCTION" missed="127" covered="2" /><counter type="LINE" missed="86" covered="2" /><counter type="METHOD" missed="5" covered="1" /><counter type="CLASS" missed="1" covered="0" /></class><class name="Helpers/Prompt" sourcefilename="Prompt.ps1"><method name="Test-IsVanillaWindow" desc="()" line="9"><counter type="INSTRUCTION" missed="7" covered="0" /><counter type="LINE" missed="2" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Test-AnsiTerminal" desc="()" line="14"><counter type="INSTRUCTION" missed="1" covered="0" /><counter type="LINE" missed="1" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Test-PsCore" desc="()" line="18"><counter type="INSTRUCTION" missed="1" covered="0" /><counter type="LINE" missed="1" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Test-Windows" desc="()" line="22"><counter type="INSTRUCTION" missed="0" covered="1" /><counter type="LINE" missed="0" covered="1" /><counter type="METHOD" missed="0" covered="1" /></method><method name="Get-Home" desc="()" line="27"><counter type="INSTRUCTION" missed="1" covered="0" /><counter type="LINE" missed="1" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Test-Administrator" desc="()" line="31"><counter type="INSTRUCTION" missed="7" covered="0" /><counter type="LINE" missed="5" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-ComputerName" desc="()" line="43"><counter type="INSTRUCTION" missed="8" covered="0" /><counter type="LINE" missed="7" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-Provider" desc="()" line="62"><counter type="INSTRUCTION" missed="1" covered="0" /><counter type="LINE" missed="1" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-FormattedRootLocation" desc="()" line="72"><counter type="INSTRUCTION" missed="9" covered="0" /><counter type="LINE" missed="9" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Test-IsVCSRoot" desc="()" line="95"><counter type="INSTRUCTION" missed="7" covered="0" /><counter type="LINE" missed="1" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-FullPath" desc="()" line="109"><counter type="INSTRUCTION" missed="10" covered="0" /><counter type="LINE" missed="7" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-OSPathSeparator" desc="()" line="125"><counter type="INSTRUCTION" missed="1" covered="0" /><counter type="LINE" missed="1" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-ShortPath" desc="()" line="135"><counter type="INSTRUCTION" missed="31" covered="0" /><counter type="LINE" missed="19" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Test-VirtualEnv" desc="()" line="169"><counter type="INSTRUCTION" missed="5" covered="0" /><counter type="LINE" missed="5" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-VirtualEnvName" desc="()" line="180"><counter type="INSTRUCTION" missed="12" covered="0" /><counter type="LINE" missed="10" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Test-NotDefaultUser" desc="()" line="198"><counter type="INSTRUCTION" missed="1" covered="0" /><counter type="LINE" missed="1" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Set-CursorForRightBlockWrite" desc="()" line="207"><counter type="INSTRUCTION" missed="5" covered="0" /><counter type="LINE" missed="4" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Reset-CursorPosition" desc="()" line="214"><counter type="INSTRUCTION" missed="3" covered="0" /><counter type="LINE" missed="3" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Set-CursorUp" desc="()" line="224"><counter type="INSTRUCTION" missed="2" covered="0" /><counter type="LINE" missed="1" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Set-Newline" desc="()" line="228"><counter type="INSTRUCTION" missed="1" covered="0" /><counter type="LINE" missed="1" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="Get-BatteryInfo" desc="()" line="232"><counter type="INSTRUCTION" missed="62" covered="0" /><counter type="LINE" missed="49" covered="0" /><counter type="METHOD" missed="1" covered="0" /></method><method name="<script>" desc="()" line="297"><counter type="INSTRUCTION" missed="0" covered="2" /><counter type="LINE" missed="0" covered="2" /><counter type="METHOD" missed="0" covered="1" /></method><counter type="INSTRUCTION" missed="175" covered="3" /><counter type="LINE" missed="129" covered="3" /><counter type="METHOD" missed="20" covered="2" /><counter type="CLASS" missed="1" covered="0" /></class><sourcefile name="PoshGit.ps1"><line nr="7" mi="1" ci="0" mb="0" cb="0" /><line nr="8" mi="1" ci="0" mb="0" cb="0" /><line nr="10" mi="1" ci="0" mb="0" cb="0" /><line nr="14" mi="1" ci="0" mb="0" cb="0" /><line nr="15" mi="1" ci="0" mb="0" cb="0" /><line nr="16" mi="1" ci="0" mb="0" cb="0" /><line nr="18" mi="1" ci="0" mb="0" cb="0" /><line nr="23" mi="2" ci="0" mb="0" cb="0" /><line nr="24" mi="1" ci="0" mb="0" cb="0" /><line nr="26" mi="1" ci="0" mb="0" cb="0" /><line nr="27" mi="1" ci="0" mb="0" cb="0" /><line nr="28" mi="1" ci="0" mb="0" cb="0" /><line nr="30" mi="1" ci="0" mb="0" cb="0" /><line nr="31" mi="1" ci="0" mb="0" cb="0" /><line nr="33" mi="1" ci="0" mb="0" cb="0" /><line nr="34" mi="1" ci="0" mb="0" cb="0" /><line nr="36" mi="1" ci="0" mb="0" cb="0" /><line nr="40" mi="1" ci="0" mb="0" cb="0" /><line nr="41" mi="1" ci="0" mb="0" cb="0" /><line nr="42" mi="1" ci="0" mb="0" cb="0" /><line nr="53" mi="1" ci="0" mb="0" cb="0" /><line nr="54" mi="1" ci="0" mb="0" cb="0" /><line nr="57" mi="2" ci="0" mb="0" cb="0" /><line nr="59" mi="7" ci="0" mb="0" cb="0" /><line nr="63" mi="1" ci="0" mb="0" cb="0" /><line nr="64" mi="1" ci="0" mb="0" cb="0" /><line nr="67" mi="3" ci="0" mb="0" cb="0" /><line nr="68" mi="1" ci="0" mb="0" cb="0" /><line nr="71" mi="1" ci="0" mb="0" cb="0" /><line nr="72" mi="1" ci="0" mb="0" cb="0" /><line nr="75" mi="1" ci="0" mb="0" cb="0" /><line nr="76" mi="1" ci="0" mb="0" cb="0" /><line nr="79" mi="1" ci="0" mb="0" cb="0" /><line nr="80" mi="1" ci="0" mb="0" cb="0" /><line nr="82" mi="1" ci="0" mb="0" cb="0" /><line nr="83" mi="1" ci="0" mb="0" cb="0" /><line nr="85" mi="1" ci="0" mb="0" cb="0" /><line nr="87" mi="1" ci="0" mb="0" cb="0" /><line nr="89" mi="1" ci="0" mb="0" cb="0" /><line nr="91" mi="5" ci="0" mb="0" cb="0" /><line nr="93" mi="1" ci="0" mb="0" cb="0" /><line nr="95" mi="3" ci="0" mb="0" cb="0" /><line nr="97" mi="1" ci="0" mb="0" cb="0" /><line nr="99" mi="3" ci="0" mb="0" cb="0" /><line nr="104" mi="1" ci="0" mb="0" cb="0" /><line nr="107" mi="1" ci="0" mb="0" cb="0" /><line nr="108" mi="1" ci="0" mb="0" cb="0" /><line nr="109" mi="1" ci="0" mb="0" cb="0" /><line nr="112" mi="2" ci="0" mb="0" cb="0" /><line nr="114" mi="1" ci="0" mb="0" cb="0" /><line nr="115" mi="2" ci="0" mb="0" cb="0" /><line nr="118" mi="1" ci="0" mb="0" cb="0" /><line nr="119" mi="1" ci="0" mb="0" cb="0" /><line nr="121" mi="1" ci="0" mb="0" cb="0" /><line nr="122" mi="3" ci="0" mb="0" cb="0" /><line nr="124" mi="1" ci="0" mb="0" cb="0" /><line nr="125" mi="3" ci="0" mb="0" cb="0" /><line nr="127" mi="1" ci="0" mb="0" cb="0" /><line nr="128" mi="3" ci="0" mb="0" cb="0" /><line nr="131" mi="1" ci="0" mb="0" cb="0" /><line nr="132" mi="3" ci="0" mb="0" cb="0" /><line nr="135" mi="1" ci="0" mb="0" cb="0" /><line nr="136" mi="2" ci="0" mb="0" cb="0" /><line nr="140" mi="1" ci="0" mb="0" cb="0" /><line nr="141" mi="1" ci="0" mb="0" cb="0" /><line nr="142" mi="1" ci="0" mb="0" cb="0" /><line nr="144" mi="1" ci="0" mb="0" cb="0" /><line nr="145" mi="3" ci="0" mb="0" cb="0" /><line nr="147" mi="1" ci="0" mb="0" cb="0" /><line nr="148" mi="3" ci="0" mb="0" cb="0" /><line nr="150" mi="1" ci="0" mb="0" cb="0" /><line nr="151" mi="3" ci="0" mb="0" cb="0" /><line nr="153" mi="1" ci="0" mb="0" cb="0" /><line nr="154" mi="3" ci="0" mb="0" cb="0" /><line nr="158" mi="1" ci="0" mb="0" cb="0" /><line nr="160" mi="1" ci="0" mb="0" cb="0" /><line nr="162" mi="1" ci="0" mb="0" cb="0" /><line nr="164" mi="1" ci="0" mb="0" cb="0" /><line nr="168" mi="1" ci="0" mb="0" cb="0" /><line nr="171" mi="1" ci="0" mb="0" cb="0" /><line nr="172" mi="2" ci="0" mb="0" cb="0" /><line nr="175" mi="1" ci="0" mb="0" cb="0" /><line nr="176" mi="4" ci="0" mb="0" cb="0" /><line nr="179" mi="1" ci="0" mb="0" cb="0" /><line nr="180" mi="1" ci="0" mb="0" cb="0" /><line nr="181" mi="1" ci="0" mb="0" cb="0" /><line nr="186" mi="0" ci="1" mb="0" cb="0" /><line nr="187" mi="0" ci="1" mb="0" cb="0" /><counter type="INSTRUCTION" missed="127" covered="2" /><counter type="LINE" missed="86" covered="2" /><counter type="METHOD" missed="5" covered="1" /><counter type="CLASS" missed="1" covered="0" /></sourcefile><sourcefile name="Prompt.ps1"><line nr="9" mi="6" ci="0" mb="0" cb="0" /><line nr="10" mi="1" ci="0" mb="0" cb="0" /><line nr="14" mi="1" ci="0" mb="0" cb="0" /><line nr="18" mi="1" ci="0" mb="0" cb="0" /><line nr="22" mi="0" ci="1" mb="0" cb="0" /><line nr="27" mi="1" ci="0" mb="0" cb="0" /><line nr="31" mi="1" ci="0" mb="0" cb="0" /><line nr="32" mi="2" ci="0" mb="0" cb="0" /><line nr="34" mi="1" ci="0" mb="0" cb="0" /><line nr="35" mi="1" ci="0" mb="0" cb="0" /><line nr="38" mi="2" ci="0" mb="0" cb="0" /><line nr="43" mi="1" ci="0" mb="0" cb="0" /><line nr="44" mi="1" ci="0" mb="0" cb="0" /><line nr="45" mi="1" ci="0" mb="0" cb="0" /><line nr="47" mi="1" ci="0" mb="0" cb="0" /><line nr="48" mi="1" ci="0" mb="0" cb="0" /><line nr="50" mi="2" ci="0" mb="0" cb="0" /><line nr="52" mi="1" ci="0" mb="0" cb="0" /><line nr="62" mi="1" ci="0" mb="0" cb="0" /><line nr="72" mi="1" ci="0" mb="0" cb="0" /><line nr="74" mi="1" ci="0" mb="0" cb="0" /><line nr="75" mi="1" ci="0" mb="0" cb="0" /><line nr="76" mi="1" ci="0" mb="0" cb="0" /><line nr="77" mi="1" ci="0" mb="0" cb="0" /><line nr="79" mi="1" ci="0" mb="0" cb="0" /><line nr="80" mi="1" ci="0" mb="0" cb="0" /><line nr="82" mi="1" ci="0" mb="0" cb="0" /><line nr="85" mi="1" ci="0" mb="0" cb="0" /><line nr="95" mi="7" ci="0" mb="0" cb="0" /><line nr="109" mi="2" ci="0" mb="0" cb="0" /><line nr="110" mi="2" ci="0" mb="0" cb="0" /><line nr="113" mi="1" ci="0" mb="0" cb="0" /><line nr="114" mi="1" ci="0" mb="0" cb="0" /><line nr="117" mi="2" ci="0" mb="0" cb="0" /><line nr="119" mi="1" ci="0" mb="0" cb="0" /><line nr="121" mi="1" ci="0" mb="0" cb="0" /><line nr="125" mi="1" ci="0" mb="0" cb="0" /><line nr="135" mi="1" ci="0" mb="0" cb="0" /><line nr="137" mi="1" ci="0" mb="0" cb="0" /><line nr="139" mi="2" ci="0" mb="0" cb="0" /><line nr="141" mi="2" ci="0" mb="0" cb="0" /><line nr="142" mi="1" ci="0" mb="0" cb="0" /><line nr="143" mi="2" ci="0" mb="0" cb="0" /><line nr="144" mi="2" ci="0" mb="0" cb="0" /><line nr="145" mi="5" ci="0" mb="0" cb="0" /><line nr="146" mi="1" ci="0" mb="0" cb="0" /><line nr="149" mi="1" ci="0" mb="0" cb="0" /><line nr="152" mi="2" ci="0" mb="0" cb="0" /><line nr="154" mi="1" ci="0" mb="0" cb="0" /><line nr="155" mi="2" ci="0" mb="0" cb="0" /><line nr="156" mi="1" ci="0" mb="0" cb="0" /><line nr="157" mi="2" ci="0" mb="0" cb="0" /><line nr="159" mi="1" ci="0" mb="0" cb="0" /><line nr="160" mi="1" ci="0" mb="0" cb="0" /><line nr="162" mi="1" ci="0" mb="0" cb="0" /><line nr="165" mi="2" ci="0" mb="0" cb="0" /><line nr="169" mi="1" ci="0" mb="0" cb="0" /><line nr="170" mi="1" ci="0" mb="0" cb="0" /><line nr="172" mi="1" ci="0" mb="0" cb="0" /><line nr="173" mi="1" ci="0" mb="0" cb="0" /><line nr="175" mi="1" ci="0" mb="0" cb="0" /><line nr="180" mi="1" ci="0" mb="0" cb="0" /><line nr="182" mi="1" ci="0" mb="0" cb="0" /><line nr="183" mi="1" ci="0" mb="0" cb="0" /><line nr="184" mi="2" ci="0" mb="0" cb="0" /><line nr="185" mi="1" ci="0" mb="0" cb="0" /><line nr="186" mi="2" ci="0" mb="0" cb="0" /><line nr="188" mi="1" ci="0" mb="0" cb="0" /><line nr="190" mi="1" ci="0" mb="0" cb="0" /><line nr="192" mi="1" ci="0" mb="0" cb="0" /><line nr="193" mi="1" ci="0" mb="0" cb="0" /><line nr="198" mi="1" ci="0" mb="0" cb="0" /><line nr="207" mi="1" ci="0" mb="0" cb="0" /><line nr="208" mi="1" ci="0" mb="0" cb="0" /><line nr="209" mi="1" ci="0" mb="0" cb="0" /><line nr="210" mi="2" ci="0" mb="0" cb="0" /><line nr="214" mi="1" ci="0" mb="0" cb="0" /><line nr="215" mi="1" ci="0" mb="0" cb="0" /><line nr="216" mi="1" ci="0" mb="0" cb="0" /><line nr="224" mi="2" ci="0" mb="0" cb="0" /><line nr="228" mi="1" ci="0" mb="0" cb="0" /><line nr="232" mi="1" ci="0" mb="0" cb="0" /><line nr="233" mi="1" ci="0" mb="0" cb="0" /><line nr="234" mi="1" ci="0" mb="0" cb="0" /><line nr="235" mi="1" ci="0" mb="0" cb="0" /><line nr="237" mi="1" ci="0" mb="0" cb="0" /><line nr="238" mi="1" ci="0" mb="0" cb="0" /><line nr="239" mi="1" ci="0" mb="0" cb="0" /><line nr="240" mi="1" ci="0" mb="0" cb="0" /><line nr="242" mi="1" ci="0" mb="0" cb="0" /><line nr="244" mi="1" ci="0" mb="0" cb="0" /><line nr="245" mi="1" ci="0" mb="0" cb="0" /><line nr="246" mi="1" ci="0" mb="0" cb="0" /><line nr="248" mi="4" ci="0" mb="0" cb="0" /><line nr="249" mi="2" ci="0" mb="0" cb="0" /><line nr="250" mi="1" ci="0" mb="0" cb="0" /><line nr="251" mi="1" ci="0" mb="0" cb="0" /><line nr="253" mi="4" ci="0" mb="0" cb="0" /><line nr="254" mi="2" ci="0" mb="0" cb="0" /><line nr="255" mi="1" ci="0" mb="0" cb="0" /><line nr="256" mi="1" ci="0" mb="0" cb="0" /><line nr="257" mi="1" ci="0" mb="0" cb="0" /><line nr="258" mi="2" ci="0" mb="0" cb="0" /><line nr="259" mi="1" ci="0" mb="0" cb="0" /><line nr="261" mi="1" ci="0" mb="0" cb="0" /><line nr="263" mi="1" ci="0" mb="0" cb="0" /><line nr="264" mi="2" ci="0" mb="0" cb="0" /><line nr="266" mi="1" ci="0" mb="0" cb="0" /><line nr="267" mi="2" ci="0" mb="0" cb="0" /><line nr="268" mi="1" ci="0" mb="0" cb="0" /><line nr="269" mi="2" ci="0" mb="0" cb="0" /><line nr="270" mi="1" ci="0" mb="0" cb="0" /><line nr="274" mi="1" ci="0" mb="0" cb="0" /><line nr="275" mi="2" ci="0" mb="0" cb="0" /><line nr="276" mi="1" ci="0" mb="0" cb="0" /><line nr="278" mi="1" ci="0" mb="0" cb="0" /><line nr="279" mi="1" ci="0" mb="0" cb="0" /><line nr="280" mi="1" ci="0" mb="0" cb="0" /><line nr="281" mi="1" ci="0" mb="0" cb="0" /><line nr="282" mi="1" ci="0" mb="0" cb="0" /><line nr="283" mi="1" ci="0" mb="0" cb="0" /><line nr="284" mi="1" ci="0" mb="0" cb="0" /><line nr="285" mi="1" ci="0" mb="0" cb="0" /><line nr="286" mi="1" ci="0" mb="0" cb="0" /><line nr="287" mi="1" ci="0" mb="0" cb="0" /><line nr="288" mi="1" ci="0" mb="0" cb="0" /><line nr="289" mi="1" ci="0" mb="0" cb="0" /><line nr="290" mi="1" ci="0" mb="0" cb="0" /><line nr="293" mi="1" ci="0" mb="0" cb="0" /><line nr="294" mi="1" ci="0" mb="0" cb="0" /><line nr="297" mi="0" ci="1" mb="0" cb="0" /><line nr="298" mi="0" ci="1" mb="0" cb="0" /><counter type="INSTRUCTION" missed="175" covered="3" /><counter type="LINE" missed="129" covered="3" /><counter type="METHOD" missed="20" covered="2" /><counter type="CLASS" missed="1" covered="0" /></sourcefile><counter type="INSTRUCTION" missed="302" covered="5" /><counter type="LINE" missed="215" covered="5" /><counter type="METHOD" missed="25" covered="3" /><counter type="CLASS" missed="2" covered="0" /></package><counter type="INSTRUCTION" missed="302" covered="5" /><counter type="LINE" missed="215" covered="5" /><counter type="METHOD" missed="25" covered="3" /><counter type="CLASS" missed="2" covered="0" /></report>
# Oh-My-Posh default settings
function Get-ThemesLocation {
$folderName = "PoshThemes"
if ($PROFILE) {
return (Join-Path (Split-Path -Parent $PROFILE) $folderName)
}
return "~\${$folderName}"
}
$global:ThemeSettings = New-Object -TypeName PSObject -Property @{
CurrentUser = [System.Environment]::UserName
CurrentHostname = [System.Environment]::MachineName
CurrentThemeLocation = "$PSScriptRoot\Themes\Agnoster.psm1"
MyThemesLocation = Get-ThemesLocation
ErrorCount = 0
GitSymbols = @{
BranchSymbol = [char]::ConvertFromUtf32(0xE0A0)
BeforeStashSymbol = '{'
BeforeIndexSymbol = ''
BeforeWorkingSymbol = ''
AfterStashSymbol = '}'
DelimSymbol = '|'
LocalWorkingStatusSymbol = '!'
LocalStagedStatusSymbol = '~'
LocalDefaultStatusSymbol = ''
BranchUntrackedSymbol = [char]::ConvertFromUtf32(0x2262)
BranchIdenticalStatusToSymbol = [char]::ConvertFromUtf32(0x2263)
BranchAheadStatusSymbol = [char]::ConvertFromUtf32(0x2191)
BranchBehindStatusSymbol = [char]::ConvertFromUtf32(0x2193)
OriginSymbols = @{
Github = [char]::ConvertFromUtf32(0xF09B)
Bitbucket = [char]::ConvertFromUtf32(0xF171)
GitLab = [char]::ConvertFromUtf32(0xF296)
}
}
PromptSymbols = @{
StartSymbol = ' '
TruncatedFolderSymbol = '..'
PromptIndicator = [char]::ConvertFromUtf32(0x25B6)
FailedCommandSymbol = [char]::ConvertFromUtf32(0x2A2F)
ElevatedSymbol = [char]::ConvertFromUtf32(0x26A1)
SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
SegmentBackwardSymbol = [char]::ConvertFromUtf32(0x26A1)
SegmentSeparatorForwardSymbol = [char]::ConvertFromUtf32(0x26A1)
SegmentSeparatorBackwardSymbol = [char]::ConvertFromUtf32(0x26A1)
PathSeparator = [System.IO.Path]::DirectorySeparatorChar
VirtualEnvSymbol = [char]::ConvertFromUtf32(0xE606)
HomeSymbol = '~'
RootSymbol = '#'
UNCSymbol = '§'
}
Colors = @{
GitDefaultColor = [ConsoleColor]::DarkGreen
GitLocalChangesColor = [ConsoleColor]::DarkYellow
GitNoLocalChangesAndAheadColor = [ConsoleColor]::DarkMagenta
GitNoLocalChangesAndBehindColor = [ConsoleColor]::DarkRed
GitNoLocalChangesAndAheadAndBehindColor = [ConsoleColor]::DarkRed
PromptForegroundColor = [ConsoleColor]::White
PromptHighlightColor = [ConsoleColor]::DarkBlue
DriveForegroundColor = [ConsoleColor]::DarkBlue
PromptBackgroundColor = [ConsoleColor]::DarkBlue
PromptSymbolColor = [ConsoleColor]::White
SessionInfoBackgroundColor = [ConsoleColor]::Black
SessionInfoForegroundColor = [ConsoleColor]::White
CommandFailedIconForegroundColor = [ConsoleColor]::DarkRed
AdminIconForegroundColor = [ConsoleColor]::DarkYellow
WithBackgroundColor = [ConsoleColor]::DarkRed
WithForegroundColor = [ConsoleColor]::White
GitForegroundColor = [ConsoleColor]::Black
VirtualEnvForegroundColor = [ConsoleColor]::White
VirtualEnvBackgroundColor = [ConsoleColor]::Red
}
Options = @{
ConsoleTitle = $true
OriginSymbols = $false
PreserveLastExitCode = $true
}
}
# PSColor default settings
$global:PSColor = @{
File = @{
Default = @{ Color = 'White' }
Directory = @{ Color = 'DarkBlue' }
Hidden = @{ Color = 'Gray'; Pattern = '^\.' }
Code = @{ Color = 'Magenta'; Pattern = '\.(java|c|cpp|cs|js|css|html)$' }
Executable = @{ Color = 'Red'; Pattern = '\.(exe|bat|cmd|py|pl|ps1|psm1|vbs|rb|reg)$' }
Text = @{ Color = 'White'; Pattern = '\.(txt|cfg|conf|ini|csv|log|config|xml|yml|md|markdown)$' }
Compressed = @{ Color = 'DarkGreen'; Pattern = '\.(zip|tar|gz|rar|jar|war)$' }
}
Service = @{
Default = @{ Color = 'White' }
Running = @{ Color = 'DarkGreen' }
Stopped = @{ Color = 'DarkYellow' }
}
Match = @{
Default = @{ Color = 'White' }
Path = @{ Color = 'Cyan' }
LineNumber = @{ Color = 'DarkGreen' }
Line = @{ Color = 'White' }
}
}
function Format-BranchName {
param(
[string]
$branchName
)
if($spg.BranchNameLimit -gt 0 -and $branchName.Length -gt $spg.BranchNameLimit) {
$branchName = ' {0}{1} ' -f $branchName.Substring(0, $spg.BranchNameLimit), $spg.TruncatedBranchSuffix
}
return " $branchName "
}
function Get-VCSStatus {
if (Get-Command Get-GitStatus -errorAction SilentlyContinue) {
$global:GitStatus = Get-GitStatus
return $global:GitStatus
}
return $null
}
function Get-BranchSymbol($upstream) {
# Add remote icon instead of branchsymbol if Enabled
if (-not ($upstream) -or !$sl.Options.OriginSymbols) {
return $sl.GitSymbols.BranchSymbol
}
$originUrl = Get-GitRemoteUrl $upstream
if ($originUrl.Contains("github")) {
return $sl.GitSymbols.OriginSymbols.Github
}
elseif ($originUrl.Contains("bitbucket")) {
return $sl.GitSymbols.OriginSymbols.Bitbucket
}
elseif ($originUrl.Contains("gitlab")) {
return $sl.GitSymbols.OriginSymbols.GitLab
}
return $sl.GitSymbols.BranchSymbol
}
function Get-GitRemoteUrl($upstream) {
$origin = $upstream -replace "/.*"
$originUrl = git remote get-url $origin
return $originUrl
}
function Get-VcsInfo {
param(
[Object]
$status,
[Parameter(Mandatory=$false)][Int] $branchNameMaxLength
)
if ($status) {
$branchStatusBackgroundColor = $sl.Colors.GitDefaultColor
# Determine Colors
$localChanges = ($status.HasIndex -or $status.HasUntracked -or $status.HasWorking)
#Git flags
$localChanges = $localChanges -or (($status.Untracked -gt 0) -or ($status.Added -gt 0) -or ($status.Modified -gt 0) -or ($status.Deleted -gt 0) -or ($status.Renamed -gt 0))
#hg/svn flags
# There are local changes
if($localChanges) {
$branchStatusBackgroundColor = $sl.Colors.GitLocalChangesColor
}
# There are no local changes and the current branch is both ahead and behind
elseif(($status.AheadBy -gt 0) -and ($status.BehindBy -gt 0)) {
$branchStatusBackgroundColor = $sl.Colors.GitNoLocalChangesAndAheadAndBehindColor
}
# There are no local changes and the current branch is ahead only
elseif ($status.AheadBy -gt 0) {
$branchStatusBackgroundColor = $sl.Colors.GitNoLocalChangesAndAheadColor
}
# There are no local changes and the current branch is behind only
elseif($status.BehindBy -gt 0) {
$branchStatusBackgroundColor = $sl.Colors.GitNoLocalChangesAndBehindColor
}
$vcInfo = Get-BranchSymbol $status.Upstream
$branchStatusSymbol = $null
if (!$status.Upstream) {
$branchStatusSymbol = $sl.GitSymbols.BranchUntrackedSymbol
}
elseif ($status.BehindBy -eq 0 -and $status.AheadBy -eq 0) {
# We are aligned with remote
$branchStatusSymbol = $sl.GitSymbols.BranchIdenticalStatusToSymbol
}
elseif ($status.BehindBy -ge 1 -and $status.AheadBy -ge 1) {
# We are both behind and ahead of remote
$branchStatusSymbol = "$($sl.GitSymbols.BranchAheadStatusSymbol)$($status.AheadBy) $($sl.GitSymbols.BranchBehindStatusSymbol)$($status.BehindBy)"
}
elseif ($status.BehindBy -ge 1) {
# We are behind remote
$branchStatusSymbol = "$($sl.GitSymbols.BranchBehindStatusSymbol)$($status.BehindBy)"
}
elseif ($status.AheadBy -ge 1) {
# We are ahead of remote
$branchStatusSymbol = "$($sl.GitSymbols.BranchAheadStatusSymbol)$($status.AheadBy)"
}
else
{
# This condition should not be possible but defaulting the variables to be safe
$branchStatusSymbol = '?'
}
$branchName = $status.Branch
if ($branchNameMaxLength -and $branchName.Length -gt $branchNameMaxLength) {
$branchName = $branchName.Substring(0, $branchNameMaxLength);
}
$vcInfo = $vcInfo + (Format-BranchName -branchName $branchName)
if ($branchStatusSymbol) {
$vcInfo = $vcInfo + ('{0} ' -f $branchStatusSymbol)
}
if($spg.EnableFileStatus -and $status.HasIndex) {
$vcInfo = $vcInfo + $sl.GitSymbols.BeforeIndexSymbol
if($spg.ShowStatusWhenZero -or $status.Index.Added) {
$vcInfo = $vcInfo + "$($spg.FileAddedText)$($status.Index.Added.Count) "
}
if($spg.ShowStatusWhenZero -or $status.Index.Modified) {
$vcInfo = $vcInfo + "$($spg.FileModifiedText)$($status.Index.Modified.Count) "
}
if($spg.ShowStatusWhenZero -or $status.Index.Deleted) {
$vcInfo = $vcInfo + "$($spg.FileRemovedText)$($status.Index.Deleted.Count) "
}
if ($status.Index.Unmerged) {
$vcInfo = $vcInfo + "$($spg.FileConflictedText)$($status.Index.Unmerged.Count) "
}
if($status.HasWorking) {
$vcInfo = $vcInfo + "$($sl.GitSymbols.DelimSymbol) "
}
}
if($spg.EnableFileStatus -and $status.HasWorking) {
if (!$status.HasIndex) {
$vcInfo = $vcInfo + $sl.GitSymbols.BeforeWorkingSymbol
}
if($spg.showStatusWhenZero -or $status.Working.Added) {
$vcInfo = $vcInfo + "$($spg.FileAddedText)$($status.Working.Added.Count) "
}
if($spg.ShowStatusWhenZero -or $status.Working.Modified) {
$vcInfo = $vcInfo + "$($spg.FileModifiedText)$($status.Working.Modified.Count) "
}
if($spg.ShowStatusWhenZero -or $status.Working.Deleted) {
$vcInfo = $vcInfo + "$($spg.FileRemovedText)$($status.Working.Deleted.Count) "
}
if ($status.Working.Unmerged) {
$vcInfo = $vcInfo + "$($spg.FileConflictedText)$($status.Working.Unmerged.Count) "
}
}
if ($status.HasWorking) {
# We have un-staged files in the working tree
$localStatusSymbol = $sl.GitSymbols.LocalWorkingStatusSymbol
}
elseif ($status.HasIndex) {
# We have staged but uncommited files
$localStatusSymbol = $sl.GitSymbols.LocalStagedStatusSymbol
}
else {
# No uncommited changes
$localStatusSymbol = $sl.GitSymbols.LocalDefaultStatusSymbol
}
if ($localStatusSymbol) {
$vcInfo = $vcInfo + ('{0} ' -f $localStatusSymbol)
}
if ($status.StashCount -gt 0) {
$vcInfo = $vcInfo + "$($sl.GitSymbols.BeforeStashSymbol)$($status.StashCount)$($sl.GitSymbols.AfterStashSymbol) "
}
return New-Object PSObject -Property @{
BackgroundColor = $branchStatusBackgroundColor
VcInfo = $vcInfo.Trim()
}
}
}
$spg = $global:GitPromptSettings #Posh-Git settings
$sl = $global:ThemeSettings #local settings
$global:ThemeSettings = New-Object -TypeName PSObject -Property @{
GitSymbols = @{
BranchSymbol = 'branch'
OriginSymbols = @{
Github = [char]::ConvertFromUtf32(0xF09B)
Bitbucket = [char]::ConvertFromUtf32(0xF171)
GitLab = [char]::ConvertFromUtf32(0xF296)
}
}
Options = @{
OriginSymbols = $false
}
}
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
. "$here\$sut"
Describe "Test-GetBranchSymbol" {
Context "Is disabled" {
BeforeAll {
$global:ThemeSettings.Options.OriginSymbols = $false
}
It "Has Enabled set to False" {
Mock Get-GitRemoteUrl { return 'github.com/test.git' }
$symbol = Get-BranchSymbol 'origin/master'
$symbol | Should Be $themeSettings.GitSymbols.BranchSymbol
}
It "Has has no upstream" {
$symbol = Get-BranchSymbol
$symbol | Should Be $themeSettings.GitSymbols.BranchSymbol
}
}
Context "Is enabled" {
BeforeAll {
$global:ThemeSettings.Options.OriginSymbols = $true
}
It "Uses GitHub" {
Mock Get-GitRemoteUrl { return 'github.com/test.git' }
$symbol = Get-BranchSymbol 'origin/master'
$symbol | Should Be $themeSettings.GitSymbols.OriginSymbols.Github
}
It "Uses GitLab" {
Mock Get-GitRemoteUrl { return 'gitlab.com/test.git' }
$symbol = Get-BranchSymbol 'origin/master'
$symbol | Should Be $themeSettings.GitSymbols.OriginSymbols.GitLab
}
It "Uses BitBucket" {
Mock Get-GitRemoteUrl { return 'bitbucket.com/test.git' }
$symbol = Get-BranchSymbol 'origin/master'
$symbol | Should Be $themeSettings.GitSymbols.OriginSymbols.Bitbucket
}
It "Uses something else" {
Mock Get-GitRemoteUrl { return 'example.com/test.git' }
$symbol = Get-BranchSymbol 'origin/master'
$symbol | Should Be $themeSettings.GitSymbols.BranchSymbol
}
It "Has no remote" {
$symbol = Get-BranchSymbol
$symbol | Should Be $themeSettings.GitSymbols.BranchSymbol
}
}
}
<#
.SYNOPSIS
Defines whether or not the current terminal supports ANSI characters
.DESCRIPTION
Logic taken from posh-git that sets the $GitPromptSettings.AnsiConsole bool:
[bool]$AnsiConsole = $Host.UI.SupportsVirtualTerminal -or ($Env:ConEmuANSI -eq "ON")
#>
function Test-IsVanillaWindow {
$hasAnsiSupport = (Test-AnsiTerminal) -or ($Env:ConEmuANSI -eq "ON") -or ($env:PROMPT) -or ($env:TERM_PROGRAM -eq "Hyper") -or ($env:TERM_PROGRAM -eq "vscode")
return !$hasAnsiSupport
}
function Test-AnsiTerminal {
return $Host.UI.SupportsVirtualTerminal
}
function Test-PsCore {
return $PSVersionTable.PSVersion.Major -gt 5
}
function Test-Windows {
$PSVersionTable.Platform -ne 'Unix'
}
function Get-Home {
# On Unix systems, $HOME comes with a trailing slash, unlike the Windows variant
return $HOME.TrimEnd('/', '\')
}
function Test-Administrator {
if ($PSVersionTable.Platform -eq 'Unix') {
return (whoami) -eq 'root'
}
elseif ($PSVersionTable.Platform -eq 'Windows') {
return $false #TO-DO: find out how to distinguish this one
}
else {
return ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] 'Administrator')
}
}
function Get-ComputerName {
if (Test-PsCore -And -Not Test-Windows) {
if ($env:COMPUTERNAME) {
return $env:COMPUTERNAME
}
if ($env:NAME) {
return $env:NAME
}
return (uname -n)
}
return $env:COMPUTERNAME
}
function Get-Provider {
param(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PathInfo]
$dir
)
return $dir.Provider.Name
}
function Get-FormattedRootLocation {
param(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PathInfo]
$dir
)
$provider = Get-Provider -dir $dir
if ($provider -eq 'FileSystem') {
$homedir = Get-Home
if ($dir.Path.StartsWith($homedir)) {
return $sl.PromptSymbols.HomeSymbol
}
if ($dir.Path.StartsWith('Microsoft.PowerShell.Core')) {
return $sl.PromptSymbols.UNCSymbol
}
return ''
}
else {
return $dir.Drive.Name
}
}
function Test-IsVCSRoot {
param(
[System.String]
$Path
)
return (Test-Path -LiteralPath "$($Path)\.git") -Or (Test-Path -LiteralPath "$($Path)\.hg") -Or (Test-Path -LiteralPath "$($Path)\.svn")
}
function Get-FullPath {
param(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PathInfo]
$dir,
[Parameter(Mandatory = $false)]
[switch]
$noHomeAbbreviation
)
if ($dir.path -eq "$($dir.Drive.Name):\") {
return "$($dir.Drive.Name):"
}
if ($noHomeAbbreviation.IsPresent) {
$path = $dir.path
}
else {
$path = $dir.path.Replace((Get-Home), $sl.PromptSymbols.HomeSymbol)
}
$path = $path.Replace('\', $sl.PromptSymbols.PathSeparator)
return $path
}
function Get-OSPathSeparator {
return [System.IO.Path]::DirectorySeparatorChar
}
function Get-ShortPath {
param(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PathInfo]
$dir
)
$provider = Get-Provider -dir $dir
if ($provider -eq 'FileSystem') {
# on UNIX systems, a trailing slash can be present, yet when calling $HOME there isn't one
$path = $dir.Path.TrimEnd((Get-OSPathSeparator))
# list known paths and their substitutes
$knownPaths = (Get-Home), 'Microsoft.PowerShell.Core\FileSystem::'
$result = @()
while ($path -And -Not ($knownPaths.Contains($path))) {
$folder = $path.Split((Get-OSPathSeparator))[-1]
if ( (Test-IsVCSRoot -Path $path) -Or ($result.length -eq 0) -Or -Not ($path.Contains((Get-OSPathSeparator)))) {
$result = , $folder + $result
}
else {
$result = , $sl.PromptSymbols.TruncatedFolderSymbol + $result
}
# remove the last element
$path = $path.TrimEnd($folder).TrimEnd((Get-OSPathSeparator))
}
$shortPath = $result -join $sl.PromptSymbols.PathSeparator
$rootLocation = (Get-FormattedRootLocation -dir $dir)
if ($rootLocation -and $shortPath) {
return "$rootLocation$($sl.PromptSymbols.PathSeparator)$shortPath"
}
if ($rootLocation) {
return $rootLocation
}
return $shortPath
}
else {
return $dir.path.Replace((Get-FormattedRootLocation -dir $dir), '')
}
}
function Test-VirtualEnv {
if ($env:VIRTUAL_ENV) {
return $true
}
if ($Env:CONDA_PROMPT_MODIFIER) {
return $true
}
return $false
}
function Get-VirtualEnvName {
# Suppress prompt from virtualenv
$env:VIRTUAL_ENV_DISABLE_PROMPT="True"
if ($env:VIRTUAL_ENV) {
if ($PSVersionTable.Platform -eq 'Unix') {
$virtualEnvName = ($env:VIRTUAL_ENV -split '/')[-1]
} elseif ($PSVersionTable.Platform -eq 'Win32NT' -or $PSEdition -eq 'Desktop') {
$virtualEnvName = ($env:VIRTUAL_ENV -split '\\')[-1]
} else {
$virtualEnvName = $env:VIRTUAL_ENV
}
return $virtualEnvName.Trim('[\/]')
}
elseif ($Env:CONDA_PROMPT_MODIFIER) {
[regex]::Match($Env:CONDA_PROMPT_MODIFIER, "^\((.*)\)").Captures.Groups[1].Value;
}
}
function Test-NotDefaultUser($user) {
return $null -eq $DefaultUser -or $user -ne $DefaultUser
}
function Set-CursorForRightBlockWrite {
param(
[int]
$textLength
)
$rawUI = $Host.UI.RawUI
$width = $rawUI.BufferSize.Width
$space = $width - $textLength
Write-Prompt "$escapeChar[$($space)G"
}
function Reset-CursorPosition {
$postion = $host.UI.RawUI.CursorPosition
$postion.X = 0
$host.UI.RawUI.CursorPosition = $postion
}
function Set-CursorUp {
param(
[int]
$lines
)
return "$escapeChar[$($lines)A"
}
function Set-Newline {
return Write-Prompt "`n"
}
function Get-BatteryInfo {
if ($env:OS -eq 'Windows_NT' -or $IsWindows) {
$cimSession = New-CimSession
$batteryclass = Get-CimInstance win32_battery -Property EstimatedChargeRemaining -CimSession $cimSession
if (!$batteryclass) { return }
$powerclass = Get-CimInstance -Class batterystatus -Namespace root\wmi -Property PowerOnline,Charging -CimSession $cimSession
$charge = $batteryclass.EstimatedChargeRemaining
$connected = $powerclass.PowerOnline
$charging = $powerclass.Charging
} elseif ($IsLinux) {
$syspath = "/sys/class/power_supply/"
$syspathcontents = Get-ChildItem $syspath
if (!$syspathcontents) { return }
$powerclass = ($syspathcontents | Where-Object { $_.Name -like 'AC*' }).Name
if ($powerclass -is [Object[]]) { $powerdevice = $syspath + $powerclass[-1] }
else { $powerdevice = $syspath + $powerclass }
$connected = Get-Content "$powerdevice/online"
$batteryclass = ($syspathcontents | Where-Object { $_.Name -like 'BAT*' }).Name
if ($batteryclass -is [Object[]]) { $batterydevice = $syspath + $batteryclass[-1] }
else { $batterydevice = $syspath + $batteryclass }
$charge = Get-Content "$batterydevice/capacity"
$chargestatus = Get-Content "$batterydevice/status"
if ($chargestatus -eq "Charging" -or $chargestatus -eq "Full") { $charging = 1 }
else { $charging = 0 }
} elseif ($IsMacOS) {
$powercommand = pmset -g ps
if ($powercommand[1] -notlike "*InternalBattery*") { "" }
$charge = $powercommand[1].Split()[3].TrimEnd('%;')
if ($powercommand[1].Split()[4].TrimEnd(';') -like 'charging') { $charging = 1 }
else { $charging = 0 }
if ($powercommand[0] -like '*Battery*') { $connected = 0 }
else { $connected = 1 }
} else { return }
if ($connected) {
if ($charging) { $batteryhex = 0xf583 }
else { $batteryhex = 0xf582 }
} else {
[int]$level = $charge / 10
switch ($level) {
0 { $batteryhex = 0xf58d }
1 { $batteryhex = 0xf579 }
2 { $batteryhex = 0xf57a }
3 { $batteryhex = 0xf57b }
4 { $batteryhex = 0xf57c }
5 { $batteryhex = 0xf57d }
6 { $batteryhex = 0xf57e }
7 { $batteryhex = 0xf57f }
8 { $batteryhex = 0xf580 }
9 { $batteryhex = 0xf581 }
Default { $batteryhex = 0xf578 }
}
}
$battery = [char]::ConvertFromUtf32($batteryhex)
return "$charge% $battery"
}
$escapeChar = [char]27
$sl = $global:ThemeSettings #local settings
$global:ThemeSettings = New-Object -TypeName PSObject -Property @{
CurrentThemeLocation = "$PSScriptRoot\Themes\Agnoster.psm1"
MyThemesLocation = '~\Documents\WindowsPowerShell\PoshThemes'
ErrorCount = 0
PromptSymbols = @{
StartSymbol = ' '
TruncatedFolderSymbol = '..'
PromptIndicator = '>'
FailedCommandSymbol = 'x'
ElevatedSymbol = '!'
SegmentForwardSymbol = '>'
SegmentBackwardSymbol = '<'
SegmentSeparatorForwardSymbol = '>'
SegmentSeparatorBackwardSymbol = '<'
PathSeparator = '\'
HomeSymbol = '*'
RootSymbol = '#'
UNCSymbol = '§'
}
}
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
. "$here\$sut"
function New-MockPath {
param (
[Parameter(Mandatory = $true)]
[System.String]
$Location,
[Parameter(Mandatory = $true)]
[System.String]
$ProviderName,
[Parameter(Mandatory = $false)]
[System.String]
$DriveName
)
$provider = New-MockObject -Type System.Management.Automation.ProviderInfo
$path = New-MockObject -Type System.Management.Automation.PathInfo
$provider | Add-Member -Type NoteProperty -Name 'Name' -Value $ProviderName -Force
$path | Add-Member -Type NoteProperty -Name 'Path' -Value $Location -Force
$path | Add-Member -Type NoteProperty -Name 'Provider' -Value $provider -Force
if ($null -ne $DriveName) {
$driveInfo = New-MockObject -Type System.Management.Automation.PSDriveInfo
$driveInfo | Add-Member -Type NoteProperty -Name 'Name' -Value $DriveName -Force
$path | Add-Member -Type NoteProperty -Name 'Drive' -Value $driveInfo -Force
}
return $path
}
Describe "Test-IsVanillaWindow" {
BeforeEach { Remove-Item Env:\ConEmuANSI -ErrorAction SilentlyContinue
Remove-Item Env:\PROMPT -ErrorAction SilentlyContinue
Remove-Item Env:\TERM_PROGRAM -ErrorAction SilentlyContinue }
Context "Running in a non-vanilla window" {
It "runs in ConEmu and outputs 'false'" {
$env:ConEmuANSI = "ON"
Mock Test-AnsiTerminal { return $false }
Test-IsVanillaWindow | Should Be $false
}
It "runs in ConEmu and outputs 'false'" {
$env:ConEmuANSI = "ON"
Mock Test-AnsiTerminal { return $true }
Test-IsVanillaWindow | Should Be $false
}
It "runs in an ANSI supported terminal and outputs 'false'" {
$env:ConEmuANSI = $false
Mock Test-AnsiTerminal { return $true }
Test-IsVanillaWindow | Should Be $false
}
It "runs in ConEmu and outputs 'false'" {
$env:ConEmuANSI = $true
Test-IsVanillaWindow | Should Be $false
}
It "runs in cmder and outputs 'false'" {
$env:PROMPT = $true
Mock Test-AnsiTerminal { return $false }
Test-IsVanillaWindow | Should Be $false
}
It "runs in cmder and conemu and outputs 'false'" {
$env:PROMPT = $true
$env:ConEmuANSI = $true
Mock Test-AnsiTerminal { return $false }
Test-IsVanillaWindow | Should Be $false
}
It "runs in Hyper.js and outputs 'false'" {
$env:TERM_PROGRAM = "Hyper"
Mock Test-AnsiTerminal { return $false }
Test-IsVanillaWindow | Should Be $false
}
It "runs in vscode and outputs 'false'" {
$env:TERM_PROGRAM = "vscode"
Mock Test-AnsiTerminal { return $false }
Test-IsVanillaWindow | Should Be $false
}
}
Context "Running in a vanilla window" {
It "runs in a vanilla window and outputs 'true'" {
Mock Test-AnsiTerminal { return $false }
Test-IsVanillaWindow | Should Be $true
}
}
}
Describe "Get-Home" {
It "returns $($HOME.TrimEnd('/','\'))" {
Get-Home | Should Be $HOME.TrimEnd('/', '\')
}
}
Describe "Get-Provider" {
It "uses the provider 'AwesomeSauce'" {
$expected = 'AwesomeSauce'
$path = New-MockPath -Location 'C:\Users\Jan\Test' -ProviderName $expected
Get-Provider $path | Should Be $expected
}
}
Describe "Get-FormattedRootLocation" {
Context "Running in the FileSystem" {
BeforeAll {
Mock Get-Home { return 'C:\Users\Jan' }
Mock Test-Windows { return $true }
}
It "is in the $HOME folder" {
$path = New-MockPath -Location 'C:\Users\Jan' -ProviderName 'FileSystem' -DriveName 'C'
Get-FormattedRootLocation $path | Should Be $ThemeSettings.PromptSymbols.HomeSymbol
}
It "is somewhere in the $HOME folder" {
$path = New-MockPath -Location 'C:\Users\Jan\Git\Somewhere' -ProviderName 'FileSystem' -DriveName 'C'
Get-FormattedRootLocation $path | Should Be $ThemeSettings.PromptSymbols.HomeSymbol
}
It "is in 'Microsoft.PowerShell.Core\FileSystem::\\Test\Hello' with Drive X:" {
$path = New-MockPath -Location 'Microsoft.PowerShell.Core\FileSystem::\\Test\Hello' -ProviderName 'FileSystem' -DriveName 'X'
Get-FormattedRootLocation $path | Should Be $ThemeSettings.PromptSymbols.UNCSymbol
}
It "is in C:" {
$path = New-MockPath -Location 'C:\Documents' -ProviderName 'FileSystem' -DriveName 'C'
Get-FormattedRootLocation $path | Should Be ''
}
It "is has no drive" {
$path = New-MockPath -Location 'J:\Test\Folder\Somewhere' -ProviderName 'FileSystem' -DriveName 'J'
Get-FormattedRootLocation $path | Should Be ''
}
It "is has no valid path" {
if (Test-PsCore) {
$true | Should Be $true
}
else {
$path = New-MockPath -Location 'J\Test\Folder\Somewhere' -ProviderName 'FileSystem' -DriveName 'J'
Get-FormattedRootLocation $path | Should Be 'J:'
}
}
}
Context "Running outside of the FileSystem" {
It "running outside of the Filesystem in L:" {
$path = New-MockPath -Location 'L:\Documents\Somewhere' -ProviderName 'SomewhereElse' -DriveName 'L'
Get-FormattedRootLocation $path | Should Be 'L'
}
}
}
Describe "Get-FullPath" {
Context "Running in the FileSystem" {
BeforeAll { Mock Get-Home { return 'C:\Users\Jan' } }
It "is in the $HOME folder" {
$path = New-MockPath -Location 'C:\Users\Jan' -ProviderName 'FileSystem' -DriveName 'C'
Get-FullPath $path | Should Be $ThemeSettings.PromptSymbols.HomeSymbol
}
It "is somewhere in the $HOME folder" {
$path = New-MockPath -Location 'C:\Users\Jan\Git\Somewhere' -ProviderName 'FileSystem' -DriveName 'C'
Get-FullPath $path | Should Be "$($ThemeSettings.PromptSymbols.HomeSymbol)\Git\Somewhere"
}
}
}
Describe "Get-ShortPath" {
if (Test-Windows) {
Context "Running in the FileSystem on Windows" {
BeforeAll {
Mock Get-Home { return 'C:\Users\Jan' }
Mock Get-OSPathSeparator { return '\' }
}
It "is in a root folder" {
$path = New-MockPath -Location 'C:\Users\' -ProviderName 'FileSystem' -DriveName 'C'
Get-ShortPath $path | Should Be "C:$($ThemeSettings.PromptSymbols.PathSeparator)Users"
}
It "is outside the $HOME folder" {
$path = New-MockPath -Location 'C:\Tools\Something' -ProviderName 'FileSystem' -DriveName 'C'
Get-ShortPath $path | Should Be "C:$($ThemeSettings.PromptSymbols.PathSeparator)$($ThemeSettings.PromptSymbols.TruncatedFolderSymbol)$($ThemeSettings.PromptSymbols.PathSeparator)Something"
}
It "is in the $HOME folder" {
$path = New-MockPath -Location 'C:\Users\Jan\' -ProviderName 'FileSystem' -DriveName 'C'
Get-ShortPath $path | Should Be $ThemeSettings.PromptSymbols.HomeSymbol
}
It "is somewhere in the $HOME folder" {
$path = New-MockPath -Location 'C:\Users\Jan\Git\Somewhere' -ProviderName 'FileSystem' -DriveName 'C'
Get-ShortPath $path | Should Be "$($ThemeSettings.PromptSymbols.HomeSymbol)$($ThemeSettings.PromptSymbols.PathSeparator)$($ThemeSettings.PromptSymbols.TruncatedFolderSymbol)$($ThemeSettings.PromptSymbols.PathSeparator)Somewhere"
}
It "is in 'Microsoft.PowerShell.Core\FileSystem::\\Test\Hello'" {
$path = New-MockPath -Location 'Microsoft.PowerShell.Core\FileSystem::\\Test\Hello' -ProviderName 'FileSystem' -DriveName 'Microsoft.PowerShell.Core'
Get-ShortPath $path | Should Be "$($ThemeSettings.PromptSymbols.UNCSymbol)$($ThemeSettings.PromptSymbols.PathSeparator)$($ThemeSettings.PromptSymbols.TruncatedFolderSymbol)$($ThemeSettings.PromptSymbols.PathSeparator)Hello"
}
}
}
if (-Not (Test-Windows)) {
Context "Running on the filesystem in UNIX" {
BeforeAll {
Mock Get-Home { return '/Users/Jan' }
Mock Get-OSPathSeparator { return '/' }
}
It "is outside the $HOME folder" {
$path = New-MockPath -Location 'C:/Tools/Something' -ProviderName 'FileSystem' -DriveName 'C'
Get-ShortPath $path | Should Be "C:$($ThemeSettings.PromptSymbols.PathSeparator)$($ThemeSettings.PromptSymbols.TruncatedFolderSymbol)$($ThemeSettings.PromptSymbols.PathSeparator)Something"
}
It "is in a root folder" {
$path = New-MockPath -Location '/Users/' -ProviderName 'FileSystem' -DriveName '/'
Get-ShortPath $path | Should Be 'Users'
}
It "is in the $HOME folder" {
$path = New-MockPath -Location '/Users/Jan/' -ProviderName 'FileSystem' -DriveName '/'
Get-ShortPath $path | Should Be $ThemeSettings.PromptSymbols.HomeSymbol
}
It "is somewhere in the $HOME folder" {
$path = New-MockPath -Location '/Users/Jan/Git/Somewhere' -ProviderName 'FileSystem' -DriveName '/'
Get-ShortPath $path | Should Be "$($ThemeSettings.PromptSymbols.HomeSymbol)$($ThemeSettings.PromptSymbols.PathSeparator)$($ThemeSettings.PromptSymbols.TruncatedFolderSymbol)$($ThemeSettings.PromptSymbols.PathSeparator)Somewhere"
}
}
}
}
Describe "Test-NotDefaultUser" {
Context "With default user set" {
BeforeAll { $DefaultUser = 'name' }
It "same username gives 'false'" {
$user = 'name'
Test-NotDefaultUser($user) | Should Be $false
}
It "different username gives 'false'" {
$user = 'differentName'
Test-NotDefaultUser($user) | Should Be $true
}
It "same username and outside VirtualEnv gives 'false'" {
Mock Test-VirtualEnv { return $false }
$user = 'name'
Test-NotDefaultUser($user) | Should Be $false
}
It "same username and inside VirtualEnv same default user gives 'false'" {
Mock Test-VirtualEnv { return $true }
$user = 'name'
Test-NotDefaultUser($user) | Should Be $false
}
It "different username and inside VirtualEnv same default user gives 'true'" {
Mock Test-VirtualEnv { return $true }
$user = 'differentName'
Test-NotDefaultUser($user) | Should Be $true
}
}
Context "With no default user set" {
BeforeAll { $DefaultUser = $null }
It "no username gives 'true'" {
Test-NotDefaultUser | Should Be $true
}
It "different username gives 'true'" {
$user = 'differentName'
Test-NotDefaultUser($user) | Should Be $true
}
It "different username and outside VirtualEnv gives 'true'" {
Mock Test-VirtualEnv { return $false }
$user = 'differentName'
Test-NotDefaultUser($user) | Should Be $true
}
It "no username and inside VirtualEnv gives 'true'" {
Mock Test-VirtualEnv { return $true }
Test-NotDefaultUser($user) | Should Be $true
}
}
}
#
# Module manifest for module 'oh-my-posh'
#
# Generated by: Jan
#
# Generated on: 28-Jun-16
#
@{
# Version number of this module.
ModuleVersion = '2.0.496'
# Script module or binary module file associated with this manifest.
RootModule = 'oh-my-posh.psm1'
# ID used to uniquely identify this module
GUID = '7d7c4a78-e2fe-4e5f-9510-34ac893e4562'
# Company or vendor of this module
CompanyName = 'Unknown'
# Author of this module
Author = 'Jan De Dobbeleer'
# Copyright statement for this module
Copyright = '(c) 2018 Jan De Dobbeleer. All rights reserved.'
# Description of the functionality provided by this module
Description = 'Theming capabilities for the PowerShell prompt in ConEmu'
# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.0'
# List of all files packaged with this module
FileList = @('defaults.ps1', 'Themes/Agnoster.psm1', 'Themes/Avit.psm1', 'Themes/Darkblood.psm1', 'Themes/Fish.psm1', 'Themes/Honukai.psm1', 'Themes/Paradox.psm1', 'Themes/Sorin.psm1', 'Helpers/PoshGit.ps1', 'Helpers/Prompt.ps1')
# Cmdlets to export from this module
CmdletsToExport = @()
# Variables to export from this module
VariablesToExport = @()
# Aliases to export from this module
AliasesToExport = '*'
# Functions to export from this module
FunctionsToExport = @('Write-ColorPreview',
'Show-Colors',
'Show-ThemeColors',
'Show-ThemeSymbols',
'Get-Theme',
'Set-Theme',
'Get-VCSStatus',
'Get-VcsInfo',
'Get-FormattedRootLocation',
'Get-ShortPath',
'Get-FullPath',
'Set-CursorForRightBlockWrite',
'Set-CursorUp',
'Test-VirtualEnv',
'Get-VirtualEnvName',
'Test-NotDefaultUser',
'Test-Administrator',
'Get-ComputerName',
'Set-Newline',
'Get-BatteryInfo',
'Get-ThemesLocation'
'Set-Prompt')
# Private data to pass to the module specified in RootModule. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('git', 'agnoster', 'theme', 'zsh', 'posh-git', 'prompt', 'paradox')
# A URL to the license for this module.
LicenseUri = 'https://github.com/JanDeDobbeleer/oh-my-posh/blob/master/LICENSE'
# A URL to the main website for this project.
ProjectUri = 'https://github.com/JanDeDobbeleer/oh-my-posh'
} # End of PSData hashtable
} # End of PrivateData hashtable
}
#requires -Version 2 -Modules posh-git
. "$PSScriptRoot\defaults.ps1"
. "$PSScriptRoot\Helpers\PoshGit.ps1"
. "$PSScriptRoot\Helpers\Prompt.ps1"
<#
.SYNOPSIS
Generates the prompt before each line in the console
#>
function Set-Prompt {
Import-Module $sl.CurrentThemeLocation -Force
[ScriptBlock]$Prompt = {
$realLASTEXITCODE = $global:LASTEXITCODE
$lastCommandFailed = ($global:error.Count -gt $sl.ErrorCount) -or -not $?
$sl.ErrorCount = $global:error.Count
#Start the vanilla posh-git when in a vanilla window, else: go nuts
if(Test-IsVanillaWindow) {
Write-Host -Object ($pwd.ProviderPath) -NoNewline
Write-VcsStatus
}
Reset-CursorPosition
$prompt = (Write-Theme -lastCommandFailed $lastCommandFailed)
if($sl.Options.ConsoleTitle) {
$location = Get-Location
$folder = $location.Path
$folderSplit = $folder -split "$([IO.Path]::DirectorySeparatorChar)", 0, "SimpleMatch"
if ($folderSplit.length -gt 3)
{
$folder = "$($folderSplit[0])", "...", "$($folderSplit[-2])", "$($folderSplit[-1])" -join "$([IO.Path]::DirectorySeparatorChar)"
}
$prompt += "$([char]27)]2;$($folder)$([char]7)"
if ($location.Provider.Name -eq "FileSystem") {
$prompt += "$([char]27)]9;9;`"$($location.Path)`"$([char]7)"
}
}
$prompt
if ($sl.Options.PreserveLastExitCode) {
$global:LASTEXITCODE = $realLASTEXITCODE
}
Remove-Variable realLASTEXITCODE -Confirm:$false
}
Set-Item -Path Function:prompt -Value $Prompt -Force
}
function global:Write-WithPrompt() {
param(
[string]
$command
)
$lastCommandFailed = $global:error.Count -gt $sl.ErrorCount
$sl.ErrorCount = $global:error.Count
if(Test-IsVanillaWindow) {
Write-ClassicPrompt -command $command
return
}
Write-Theme -lastCommandFailed $lastCommandFailed -with $command
}
function Show-ThemeColors {
##############################
#.SYNOPSIS
# Show Current Theme Colors
#
#.DESCRIPTION
# Good for checking if your current color mappings
# work well with the theme.
#
##############################
Write-Host -Object ''
$sl.Colors.Keys | Sort-Object | ForEach-Object { Write-ColorPreview -text $_ -color $sl.Colors[$_] }
Write-Host -Object ''
}
function Show-ThemeSymbols {
##############################
#.SYNOPSIS
# Show Current Theme Symbols
#
#.DESCRIPTION
# Good for checking if your current font supports
# all the symbols the theme uses.
#
##############################
Write-Host -Object "`n--PromptSymbols--`n"
$sl.PromptSymbols.Keys | Sort-Object | ForEach-Object { Write-Host -Object ("{0,3} {1}" -f $sl.PromptSymbols[$_], $_) }
Write-Host -Object ''
Write-Host -Object "`n--GitSymbols--`n"
$sl.GitSymbols.Keys | Sort-Object | ForEach-Object { Write-Host -Object ("{0,3} {1}" -f $sl.GitSymbols[$_], $_) }
Write-Host -Object ''
}
function Write-ColorPreview {
param
(
[string]
$text,
[ConsoleColor]
$color
)
$display = Write-Prompt -Object (" {0,-40}" -f $text)
$display += Write-Prompt -Object (" {0,-40}" -f $color.ToString()) -BackgroundColor $color
Write-Host $display
}
function Show-Colors {
foreach ($color in [enum]::GetValues([ConsoleColor])) {
Write-ColorPreview -text $color -color $color
}
}
function Set-Theme {
param(
[Parameter(Mandatory=$true)]
[string]
$name
)
if (Test-Path "$($sl.MyThemesLocation)\$($name).psm1") {
$sl.CurrentThemeLocation = "$($sl.MyThemesLocation)\$($name).psm1"
}
elseif (Test-Path "$PSScriptRoot\Themes\$($name).psm1") {
$sl.CurrentThemeLocation = "$PSScriptRoot\Themes\$($name).psm1"
}
elseif (Test-Path "$name") {
$sl.CurrentThemeLocation = "$name"
}
else {
Write-Host ''
Write-Warning "Theme $name not found. Available themes are:"
Get-Theme
}
Set-Prompt
}
# Helper function to create argument completion results
function New-CompletionResult {
param(
[Parameter(Mandatory)]
[string]$CompletionText,
[string]$ListItemText = $CompletionText,
[System.Management.Automation.CompletionResultType]$CompletionResultType = [System.Management.Automation.CompletionResultType]::ParameterValue,
[string]$ToolTip = $CompletionText
)
New-Object System.Management.Automation.CompletionResult $CompletionText, $ListItemText, $CompletionResultType, $ToolTip
}
function Get-Theme {
##############################
#.SYNOPSIS
# Get available theme(s)
#.DESCRIPTION
# Shows available themes, as well as their type and location
# - Defaults (shipped with module)
# - User (user defined themes)
##############################
$themes = @()
if (Test-Path "$($ThemeSettings.MyThemesLocation)\*") {
Get-ChildItem -Path "$($ThemeSettings.MyThemesLocation)\*" -Include '*.psm1' -Exclude Tools.ps1 | ForEach-Object -Process {
$themes += [PSCustomObject]@{
Name = $_.BaseName
Type = "User"
Location = $_.FullName
}
}
}
Get-ChildItem -Path "$PSScriptRoot\Themes\*" -Include '*.psm1' -Exclude Tools.ps1 | Sort-Object Name | ForEach-Object -Process {
$themes += [PSCustomObject]@{
Name = $_.BaseName
Type = "Defaults"
Location = $_.FullName
}
}
$themes
}
function ThemeCompletion {
param(
$commandName,
$parameterName,
$wordToComplete,
$commandAst,
$fakeBoundParameter
)
$themes = Get-Theme
$themes |
Where-Object { $_.Name.ToLower().StartsWith($wordToComplete.ToLower()); } |
Select-Object -Unique -ExpandProperty Name |
ForEach-Object { New-CompletionResult -CompletionText $_ }
}
Register-ArgumentCompleter `
-CommandName Set-Theme `
-ParameterName name `
-ScriptBlock $function:ThemeCompletion
$sl = $global:ThemeSettings #local settings
$sl.ErrorCount = $global:error.Count
# oh-my-posh
[![Build status][build-status-badge]][build-status]
[![Travis build status][travis-build-status-badge]][travis-build-status]
[![Coverage Status][coverage-status-badge]][coverage-status]
[![Gitter][gitter-badge]][gitter]
[![PS Gallery][psgallery-badge]][powershell-gallery]
## ⤠Support ā¤
[![Patreon][patreon-badge]][patreon]
[![Liberapay][liberapay-badge]][liberapay]
[![Ko-Fi][kofi-badge]][kofi]
## Introducing V3 and what it means for V2
It's been an amazing ride for Oh myPosh, but the time has come to step it up a notch.
Developers nowadays no longer stick to one shell/language, they are all tools we use to solve a certain problem.
The same needs to apply to Oh my Posh. It's time to adjust to that philosophy.
That's why this version of Oh my Posh is entering maintenance mode while I'm working hard on getting [V3][v3] out of the door.
Given that [V3][v3] is entirely different under the hood, it's hosted [separately][v3] for now.
From a user perspective, it should give the same experience out-of-the-box, with the added advantage
that custom themes are a first class, no code citizen.
Right now, [V3][v3] is in beta, and you can install it the same way you're used to if you want to give it a spin.
```powershell
Install-Module oh-my-posh -Scope CurrentUser -AllowPrerelease
```
[Documentation][docs-v3] is also available which should give a better experience than this **README** has over the past few years :-)
If you're a developer looking to add functionality, please have a look at [V3][v3] to see if it already exists there.
If not, feel free to create an issue or PR on [V3][v3], _**I will only be accepting bug fixes on V2 from now on**_.
## Table of Contents
- [About](#about)
- [Prerequisites](#prerequisites)
- [Installation](#installation)
- [Configuration](#configuration)
- [Helper functions](#helper-functions)
- [Themes](#themes)
## About
A theme engine for Powershell inspired by the work done by Chris Benti on [PS-Config][chrisbenti-psconfig] and [Oh-My-ZSH][oh-my-zsh] on OSX and Linux (hence the name).
More information about why I made this can be found on my [blog].
![Theme][img-indications]
Features:
- Easy installation
- Awesome prompt themes for PowerShell in ConEmu
- Git status indications (powered by posh-git)
- Failed command indication
- Admin indication
- Current session indications (admin, failed command, user)
- Configurable
- Easily create your own theme
- Separate settings for oh-my-posh and posh-git
- Does not mess with the default Powershell console
## Prerequisites
You should use a modern console host like [ConEmu][conemu], [Alacritty][alacritty], [Terminus][terminus], [Hyper][hyper], [FluentTerminal][fluentterminal], or the official [Windows Terminal][windowsterminal] to have a great terminal experience on Windows.
There are multiple ways to acquire Windows Terminal - from the Microsoft [Store](https://www.microsoft.com/en-us/p/windows-terminal/9n0dx20hk701), the GitHub [repo](https://github.com/microsoft/terminal/releases), or the below commandline methods:
Via [WinGet][winget] (official package manager for Windows):
```powershell
winget install --id=Microsoft.WindowsTerminal -e
```
Via [Chocolatey][chocolatey]:
```powershell
choco install microsoft-windows-terminal
```
Via [Scoop][scoop]:
```powershell
scoop install windows-terminal
```
The fonts I use are Powerline fonts, there is a great [repository][nerdfonts] containing them.
I use `Meslo LG M Regular for Powerline Nerd Font` in my ConEmu setup together with custom colors. You can find my theme [here][theme-gist].
In case you notice weird glyphs after installing a font of choice, make sure the glyphs are available (maybe they have a different location in the font, if so, adjust the correct `$ThemeSettings` icon). If it turns out the character you want is not supported, select a different font.
## Installation
You need to use the [PowerShell Gallery][powershell-gallery] to install oh-my-posh.
Install posh-git and oh-my-posh:
```powershell
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
```
Enable the prompt:
```powershell
# Start the default settings
Set-Prompt
# Alternatively set the desired theme:
Set-Theme Agnoster
```
In case you're running this on PS Core, make sure to also install version 2.0.0-beta1 of `PSReadLine`
```powershell
Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
```
To enable the engine edit your PowerShell profile:
```powershell
if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
notepad $PROFILE
```
Append the following lines to your PowerShell profile:
```powershell
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Paradox
```
The last command sets the theme for the console. Check the available themes list below.
## Configuration
List the current configuration:
```powershell
$ThemeSettings
```
![Theme][img-themesettings]
You can tweak the settings by manipulating `$ThemeSettings`.
This example allows you to tweak the branch symbol using a unicode character:
```powershell
$ThemeSettings.GitSymbols.BranchSymbol = [char]::ConvertFromUtf32(0xE0A0)
```
Also do not forget the Posh-Git settings itself (enable the stash indication for example):
```powershell
$GitPromptSettings
```
Hide your `[email protected]` when not in a virtual machine for the Agnoster, Fish, Honukai, Paradox and Sorin themes:
```powershell
$DefaultUser = 'yourUsernameHere'
```
## Helper functions
`Set-Theme`: set a theme from the Themes directory. If no match is found, it will not be changed. Autocomplete is available to list and complete available themes.
```powershell
Set-Theme paradox
```
`Show-ThemeColors`: display the colors used by the theme
![Theme][img-themecolors]
`Show-Colors`: display colors configured in ConEmu
![Theme][img-showcolors]
## Themes
### Agnoster
![Agnoster Theme][img-theme-agnoster]
### Paradox
![Paradox Theme][img-theme-paradox]
### Sorin
![Sorin Theme][img-theme-sorin]
### Darkblood
![Darkblood Theme][img-theme-darkblood]
### Avit
![Avit Theme][img-theme-avit]
### Honukai
![Honukai Theme][img-theme-honukai]
### Fish
![Fish Theme][img-theme-fish]
### Robbyrussell
![Robbyrussell Theme][img-theme-robbyrussell]
### Pararussel
![Pararussel Theme][img-theme-pararussell]
### Material
![Material Theme][img-theme-material]
![Material Theme][img-theme-material2]
### Star
![Star Theme][img-theme-star]
### Zash
![Star Theme][img-theme-zash]
### Lambda

### Emodipt
![Emodipt Theme][img-theme-emodipt]
### Operator
![Operator Theme][img-theme-operator]
## Creating your own theme
If you want to create a theme it can be done rather easily by adding a `mytheme.psm1` file in the folder indicated in `$ThemeSettings.MyThemesLocation` (the folder defaults to `~\Documents\WindowsPowerShell\PoshThemes`, feel free to change it).
The only required function is `Write-Theme`. You can use the following template to get started:
```powershell
#requires -Version 2 -Modules posh-git
function Write-Theme
{
param(
[bool]
$lastCommandFailed,
[string]
$with
)
# enter your prompt building logic here
}
$sl = $global:ThemeSettings #local settings
```
Feel free to use the public helper functions `Get-VCSStatus`, `Get-VcsInfo`, `Get-FormattedRootLocation`, `Get-ShortPath`, `Set-CursorForRightBlockWrite`, `Set-CursorUp`, `Set-Newline` or add your own logic completely.
To test the output in ConEmu, just switch to your theme:
```powershell
Set-Theme mytheme
```
If you want to include your theme in oh-my-posh, send me a PR and I'll try to give feedback ASAP.
Happy theming!
### Adding stack count to a custom theme
As it seems getting access to the stack information when using pushd/popd is sort of mission impossible from within a theme, you can use a workaround proposed by [Jonathan Leech-Pepin][jleechpe]. In your `$PROFILE`, add a variable that will act as a correctly scoped pointer to fetch the stack context:
```powershell
$getStackContext = {Get-Location -Stack}
```
Next, in your custom theme, access the information you want to display:
```powershell
$stackCount = (&$getStackContext).count
```
### iTerm2 is creating notifications every time
This is caused by the `ConsoleTitle` functionality.
As explained by [Andrew Stanton-Nurse][consoletitle] it's linked to how terminals work with OSC codes.
The fix is to disable the `ConsoleTitle` functionality when in iTerm2 by adding the following snippet to your `$PROFILE`.
```powershell
if($env:LC_TERMINAL -eq "iTerm2") {
$ThemeSettings.Options.ConsoleTitle = $false
}
```
### Based on work by
- [Chris Benti][chrisbenti-psconfig]
- [Keith Dahlby][keithdahlby-poshgit]
[build-status-badge]: https://img.shields.io/appveyor/ci/janjoris/oh-my-posh/master.svg?maxAge=2592000
[build-status]: https://ci.appveyor.com/project/JanJoris/oh-my-posh
[travis-build-status-badge]: https://travis-ci.org/JanDeDobbeleer/oh-my-posh.svg?branch=master
[travis-build-status]: https://travis-ci.org/JanDeDobbeleer/oh-my-posh
[coverage-status-badge]: https://coveralls.io/repos/github/JanDeDobbeleer/oh-my-posh/badge.svg
[coverage-status]: https://coveralls.io/github/JanDeDobbeleer/oh-my-posh
[gitter-badge]: https://badges.gitter.im/oh-my-posh/Lobby.svg
[gitter]: https://gitter.im/oh-my-posh/general?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge
[psgallery-badge]: https://img.shields.io/powershellgallery/dt/oh-my-posh.svg
[powershell-gallery]: https://www.powershellgallery.com/packages/oh-my-posh/
[patreon-badge]: https://img.shields.io/badge/Support-Become%20a%20Patreon!-red.svg
[patreon]: https://www.patreon.com/jandedobbeleer
[liberapay-badge]: https://img.shields.io/badge/Liberapay-Donate-%23f6c915.svg
[liberapay]: https://liberapay.com/jandedobbeleer
[kofi-badge]: https://img.shields.io/badge/Ko--fi-Buy%20me%20a%20coffee!-%2346b798.svg
[kofi]: https://ko-fi.com/jandedobbeleer
[scoop]: https://scoop.sh/
[scoop-extras]: https://github.com/lukesampson/scoop/wiki/Buckets
[windowsterminal]: https://github.com/microsoft/terminal
[conemu]: https://conemu.github.io/
[alacritty]: https://github.com/alacritty/alacritty
[terminus]: https://eugeny.github.io/terminus/
[fluentterminal]: https://github.com/felixse/FluentTerminal
[hyper]: https://hyper.is/
[winget]: https://github.com/microsoft/winget-cli
[chrisbenti-psconfig]: https://github.com/chrisbenti/PS-Config
[keithdahlby-poshgit]: https://github.com/dahlbyk/posh-git
[jleechpe]: https://github.com/jleechpe
[oh-my-zsh]: https://github.com/robbyrussell/oh-my-zsh
[blog]: https://blog.itdepends.be/shell-shock/
[chocolatey]: https://chocolatey.org/
[nerdfonts]: https://github.com/ryanoasis/nerd-fonts
[theme-gist]: https://gist.github.com/JanDeDobbeleer/71c9f1361a562f337b855b75d7bbfd28
[img-indications]: img/indications.png
[img-themesettings]: img/themesettings.png
[img-themecolors]: img/themecolors.png
[img-showcolors]: img/showcolors.png
[img-theme-agnoster]: img/agnoster.png
[img-theme-paradox]: img/paradox.png
[img-theme-sorin]: img/sorin.png
[img-theme-darkblood]: img/darkblood.png
[img-theme-avit]: img/avit.png
[img-theme-honukai]: img/honukai.png
[img-theme-fish]: img/fish.png
[img-theme-robbyrussell]: img/robbyrussel.png
[img-theme-pararussell]: img/pararussel.png
[img-theme-material]: img/material.png
[img-theme-material2]: img/material2.png
[img-theme-star]: img/star.png
[img-theme-zash]: img/zash.png
[img-theme-emodipt]: img/emodipt.png
[img-theme-operator]: img/operator.png
[consoletitle]: https://github.com/JanDeDobbeleer/oh-my-posh/issues/261#issuecomment-649701607
[v3]: https://github.com/JanDeDobbeleer/oh-my-posh3
[docs-v3]: https://ohmyposh.dev
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$lastColor = $sl.Colors.PromptBackgroundColor
$prompt=''
if($sl.PromptSymbols.StartSymbol -ne ' ') {
$prompt += Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
$user = $sl.CurrentUser
$computer = $sl.CurrentHostname
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object "[email protected]$computer " -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -ForegroundColor $sl.Colors.VirtualEnvForegroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.VirtualEnvBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
else {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
# Writes the drive portion
$prompt += Write-Prompt -Object (Get-ShortPath -dir $pwd) -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$prompt += Write-Prompt -Object ' ' -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$lastColor = $themeInfo.BackgroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $sl.Colors.PromptBackgroundColor -BackgroundColor $lastColor
$prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -BackgroundColor $lastColor -ForegroundColor $sl.Colors.GitForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor -BackgroundColor $sl.Colors.WithBackgroundColor
$prompt += Write-Prompt -Object " $($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
$lastColor = $sl.Colors.WithBackgroundColor
}
# Writes the postfix to the prompt
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.GitForegroundColor = [ConsoleColor]::Black
$sl.Colors.WithForegroundColor = [ConsoleColor]::White
$sl.Colors.WithBackgroundColor = [ConsoleColor]::DarkRed
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Red
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
# path
$sPath = "$(Get-FullPath -dir $pwd) "
#$getStackContext = {Get-Location -Stack}
#$stackCount = (&$getStackContext).count
# check for elevated prompt
$sAdmin = ""
If (Test-Administrator) {
$sAdmin = " $($sl.PromptSymbols.ElevatedSymbol)"
}
# timestamp
$sTime = " $(Get-Date -Format HH:mm:ss)"
# check the last command state and indicate if failed
$sFailed = ""
If ($lastCommandFailed) {
$sFailed = " $($sl.PromptSymbols.FailedCommandSymbol)"
}
# virtualenv
$sVenv = ""
If (Test-VirtualEnv) {
$sVenv = " $(Get-VirtualEnvName)"
}
# with
$sWith = ""
If ($with) {
$sWith = " $($with.ToUpper())"
}
$rightPrompt = "$sFailed$sWith$sVenv$sAdmin$sTime"
$prompt = ""
$prompt += Set-CursorForRightBlockWrite -textLength $rightPrompt.Length
$prompt += Write-Prompt -Object $sFailed -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor
$prompt += Write-Prompt -Object $sWith -ForegroundColor $sl.Colors.WithForegroundColor
$prompt += Write-Prompt -Object $sVenv -ForegroundColor $sl.Colors.VirtualEnvForegroundColor
$prompt += Write-Prompt -Object $sAdmin -ForegroundColor $sl.Colors.AdminIconForegroundColor
$prompt += Write-Prompt -Object $sTime -ForegroundColor $sl.colors.TimestampForegroundColor
$prompt += Write-Prompt -Object "`r"
$lastColor = $sl.Colors.PromptBackgroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$prompt += Write-Prompt -Object " $($sPath)" -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $lastColor
# git info
$vcsStatus = Get-VCSStatus
if ($vcsStatus) {
$vcsInfo = Get-VcsInfo -status $vcsStatus
$lastColor = $vcsInfo.BackgroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $sl.Colors.PromptBackgroundColor -BackgroundColor $lastColor
if (!$sl.ColorizeVcInfoItems) {
$prompt += Write-Prompt -Object " $($vcsInfo.VcInfo) " -ForegroundColor $sl.Colors.GitForegroundColor -BackgroundColor $lastColor
}
else {
$settings = $global:GitPromptSettings
# Get the GIT Status Items
$prompt2 = ""
if ($settings.DefaultPromptWriteStatusFirst) {
$prompt2 += Write-Prompt $settings.PathStatusSeparator -BackgroundColor $lastColor
}
$prompt2 += Write-Prompt -Object " $($sl.GitSymbols.BranchSymbol) " -ForegroundColor $sl.Colors.GitForegroundColor -BackgroundColor $lastColor
$prompt2 += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor -BackgroundColor $global:settings.BranchColor.BackgroundColor
$prompt2 += Write-GitBranchName $vcsStatus
$prompt2 += Write-GitBranchStatus $vcsStatus
$prompt2 += Write-Prompt $settings.BeforeIndex
if ($settings.EnableFileStatus) {
if ($vcsStatus.HasIndex) {
$prompt2 += Write-GitIndexStatus $vcsStatus
}
if ($vcsStatus.HasWorking) {
$prompt2 += Write-Prompt $settings.DelimStatus.Text -ForegroundColor $sl.Colors.GitForegroundColor
$prompt2 += Write-GitWorkingDirStatus $vcsStatus
}
}
$prompt2 += Write-GitWorkingDirStatusSummary $vcsStatus
if ($settings.EnableStashStatus -and ($vcsStatus.StashCount -gt 0)) {
$prompt2 += Write-GitStashCount $vcsStatus
}
# When status is first, place the separator after the status summary
if (!$settings.DefaultPromptWriteStatusFirst) {
$prompt2 += Write-Prompt $settings.PathStatusSeparator -BackgroundColor $lastColor
}
$prompt += Write-Prompt -Object $prompt2 -BackgroundColor $lastColor
}
}
If ($sl.DoubleCommandLine) {
$prompt += Set-Newline
}
# Writes the postfixes to the prompt
$indicatorColor = If ($lastCommandFailed) { $sl.Colors.CommandFailedIconForegroundColor } Else { $lastColor }
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $indicatorColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.Colors.DriveForegroundColor = [ConsoleColor]::DarkBlue
$sl.Colors.GitDefaultColor = [ConsoleColor]::DarkGreen
$sl.Colors.GitLocalChangesColor = [ConsoleColor]::DarkYellow
$sl.Colors.GitNoLocalChangesAndAheadAndBehindColor = [ConsoleColor]::DarkRed
$sl.Colors.GitNoLocalChangesAndAheadColor = [ConsoleColor]::DarkMagenta
$sl.Colors.GitNoLocalChangesAndBehindColor = [ConsoleColor]::DarkRed
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.SessionInfoBackgroundColor = [ConsoleColor]::Black
$sl.Colors.SessionInfoForegroundColor = [ConsoleColor]::White
$sl.Colors.WithBackgroundColor = [ConsoleColor]::DarkRed
$sl.Colors.VirtualEnvBackgroundColor = [ConsoleColor]::Red
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.WithForegroundColor = [ConsoleColor]::White
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White
$sl.Colors.TimestampForegroundColor = [ConsoleColor]::DarkCyan
$sl.Colors.CommandFailedIconForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.PromptBackgroundColor = [ConsoleColor]::DarkBlue
if ($sl.ColorizeVcInfoItems) {
$sl.Colors.GitForegroundColor = [ConsoleColor]::Black
$sl.Colors.AdminIconForegroundColor = [ConsoleColor]::White
}
else {
$sl.Colors.GitForegroundColor = [ConsoleColor]::DarkGray
$sl.Colors.AdminIconForegroundColor = [ConsoleColor]::DarkYellow
}
$global:GitPromptSettings.EnableStashStatus = $true
$sl | Add-Member -NotePropertyName DoubleCommandLine -NotePropertyValue 0 -Force
$sl | Add-Member -NotePropertyName ColorizeVcInfoItems -NotePropertyValue 0 -Force
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptForegroundColor
$dir = Get-FullPath -dir $pwd
$prompt += Write-Prompt -Object $dir -ForegroundColor $sl.Colors.PromptForegroundColor
$status = Get-VCSStatus
if ($status) {
$vcsInfo = Get-VcsInfo -status ($status)
$info = $vcsInfo.VcInfo
$prompt += Write-Prompt -Object " $info" -ForegroundColor $vcsInfo.BackgroundColor
}
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object " $($sl.PromptSymbols.ElevatedSymbol)" -ForegroundColor $sl.Colors.AdminIconForegroundColor
}
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object " $($sl.PromptSymbols.FailedCommandSymbol)" -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor
}
$timeStamp = Get-Date -Format T
$clock = [char]::ConvertFromUtf32(0x25F7)
$timestamp = "$clock $timeStamp"
if ($status) {
$timeStamp = Get-TimeSinceLastCommit
}
$prompt += Set-CursorForRightBlockWrite -textLength $timestamp.Length
$prompt += Write-Prompt $timeStamp -ForegroundColor $sl.Colors.PromptBackgroundColor
$prompt += Set-Newline
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor -ForegroundColor $sl.Colors.VirtualEnvForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.PromptBackgroundColor
$prompt += ' '
$prompt
}
function Get-TimeSinceLastCommit {
return (git log --pretty=format:'%cr' -1)
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.StartSymbol = ''
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x25B6)
$sl.Colors.PromptForegroundColor = [ConsoleColor]::DarkBlue
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Magenta
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::Red
#requires -Version 2 -Modules posh-git
function Write-Theme
{
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$user = $sl.CurrentUser
$prompt = Write-Prompt -Object ("$user ") -ForegroundColor $sl.Colors.UsernameForegroundColor
$prompt += Write-Prompt -Object (":: ") -ForegroundColor $sl.Colors.SeparatorForegroundColor
$drive = $sl.PromptSymbols.HomeSymbol
if ($pwd.Path -ne $HOME) {
$drive = "$(Split-Path -path $pwd -Leaf)"
}
$prompt += Write-Prompt -Object ($drive + " ") -ForegroundColor $sl.Colors.DriveForegroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x00BB)
$sl.Colors.UsernameForegroundColor = [ConsoleColor]::Blue
$sl.Colors.SeparatorForegroundColor = [ConsoleColor]::Red
$sl.Colors.DriveForegroundColor = [ConsoleColor]::Green
$sl.Colors.PromptForegroundColor = [ConsoleColor]::Magenta
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$prompt = Write-Prompt -Object ([char]::ConvertFromUtf32(0x250C)) -ForegroundColor $sl.Colors.PromptSymbolColor
$user = $sl.CurrentUser
$computer = $sl.CurrentHostname
$prompt += Write-Segment -content "[email protected]$computer" -foregroundColor $sl.Colors.PromptForegroundColor
# $prompt += "$($sl.PromptSymbols.SegmentForwardSymbol) "
$status = Get-VCSStatus
if ($status) {
$vcsInfo = Get-VcsInfo -status ($status)
$info = $vcsInfo.VcInfo
$prompt += Write-Segment -content $info -foregroundColor $sl.Colors.GitForegroundColor
}
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Segment -content $sl.PromptSymbols.ElevatedSymbol -foregroundColor $sl.Colors.AdminIconForegroundColor
}
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Segment -content $sl.PromptSymbols.FailedCommandSymbol -foregroundColor $sl.Colors.CommandFailedIconForegroundColor
}
$prompt += ''
# SECOND LINE
$prompt += Set-Newline
$prompt += Write-Prompt -Object ([char]::ConvertFromUtf32(0x2514)) -ForegroundColor $sl.Colors.PromptSymbolColor
$path += Get-FullPath -dir $pwd
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentBackwardSymbol -ForegroundColor $sl.Colors.PromptSymbolColor
$prompt += Write-Prompt -Object $path -ForegroundColor $sl.Colors.PromptForegroundColor
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) $($sl.PromptSymbols.SegmentBackwardSymbol)" -ForegroundColor $sl.Colors.PromptSymbolColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName)" -ForegroundColor $sl.Colors.VirtualEnvForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) $($sl.PromptSymbols.SegmentBackwardSymbol)" -ForegroundColor $sl.Colors.PromptSymbolColor
$prompt += Write-Prompt -Object "$($with.ToUpper())" -ForegroundColor $sl.Colors.WithForegroundColor
}
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol)$($sl.PromptSymbols.PromptIndicator)" -ForegroundColor $sl.Colors.PromptSymbolColor
$prompt += ' '
$prompt
}
function Write-Segment {
param(
$content,
$foregroundColor
)
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentBackwardSymbol -ForegroundColor $sl.Colors.PromptSymbolColor
$prompt += Write-Prompt -Object $content -ForegroundColor $foregroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.PromptSymbolColor
return $prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = '>'
$sl.PromptSymbols.SegmentForwardSymbol = ']'
$sl.PromptSymbols.SegmentBackwardSymbol = '['
$sl.PromptSymbols.PathSeparator = '\'
$sl.PromptSymbols.FailedCommandSymbol = 'x'
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::DarkRed
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.GitForegroundColor = [ConsoleColor]::White
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkYellow
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Magenta
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
# timestamp
$prompt = Write-Prompt -Object "[ $(Get-Date -Format HH:mm:ss) ] " -ForegroundColor $sl.colors.TimestampForegroundColor
# check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) "
}
# path
$prompt += Write-Prompt -Object "$(Get-ShortPath -dir $pwd) " -ForegroundColor $sl.Colors.DriveForegroundColor
# virtualenv
If (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$(Get-VirtualEnvName) " -ForegroundColor $sl.Colors.VirtualEnvForegroundColor
}
# git info
If ($status = Get-VCSStatus) {
$vcsInfo = Get-VcsInfo -status ($status)
$prompt += Write-Prompt -Object "$($vcsInfo.VcInfo) " -ForegroundColor $vcsInfo.BackgroundColor
}
# with
If ($with) {
$prompt += Write-Prompt -Object " $($with.ToUpper()) " -ForegroundColor $sl.Colors.WithBackgroundColor
}
# Writes the postfixes to the prompt
$indicatorColor = If ($lastCommandFailed) { $sl.Colors.CommandFailedIconForegroundColor } Else { $sl.Colors.PromptSymbolColor }
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $indicatorColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.GitSymbols.BranchSymbol = [char]::ConvertFromUtf32(0x1F6A6)
$sl.GitSymbols.BranchAheadStatusSymbol = [char]::ConvertFromUtf32(0x2B6B)
$sl.GitSymbols.BranchBehindStatusSymbol = [char]::ConvertFromUtf32(0x2B6D)
$sl.GitSymbols.BranchIdenticalStatusToSymbol = [char]::ConvertFromUtf32(0x2705)
$sl.GitSymbols.BranchUntrackedSymbol = [char]::ConvertFromUtf32(0x274E)
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Green
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::Magenta
$sl.Colors.TimestampForegroundColor = [ConsoleColor]::DarkYellow
$sl | Add-Member -NotePropertyName DoubleCommandLine -NotePropertyValue 0 -Force
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$date = Get-Date -UFormat %d-%m-%Y
$timeStamp = Get-Date -UFormat %R
$leftText = "$($sl.PromptSymbols.SegmentBackwardSymbol) $date $($sl.PromptSymbols.SegmentSeparatorBackwardSymbol) $timeStamp "
$prompt += Set-CursorUp -lines 1
$prompt += Set-CursorForRightBlockWrite -textLength $leftText.Length
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentBackwardSymbol)" -ForegroundColor $sl.Colors.PromptBackgroundColor -BackgroundColor $sl.Colors.PromptHighlightColor
$prompt += Write-Prompt " $date $($sl.PromptSymbols.SegmentSeparatorBackwardSymbol) $timeStamp " -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
# Write the prompt
$prompt += Set-Newline
$prompt += Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
# Check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
$user = $sl.CurrentUser
$computer = $sl.CurrentHostname
$path = Get-FullPath -dir $pwd
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object "[email protected]$computer " -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -ForegroundColor $sl.Colors.VirtualEnvForegroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.VirtualEnvBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
else {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
# Writes the drive portion
$prompt += Write-Prompt -Object "$path " -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentSeparatorForwardSymbol -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
if ($with) {
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentSeparatorForwardSymbol -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$prompt += Write-Prompt -Object " $($with.ToUpper()) " -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
# Writes the postfix to the prompt
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $sl.Colors.PromptBackgroundColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.StartSymbol = ''
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
$sl.PromptSymbols.SegmentBackwardSymbol = [char]::ConvertFromUtf32(0xE0B2)
$sl.PromptSymbols.SegmentSeparatorForwardSymbol = [char]::ConvertFromUtf32(0xE0B1)
$sl.PromptSymbols.SegmentSeparatorBackwardSymbol = [char]::ConvertFromUtf32(0xE0B3)
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Magenta
$sl.Colors.GitForegroundColor = [ConsoleColor]::Black
$sl.Colors.WithForegroundColor = [ConsoleColor]::White
$sl.Colors.WithBackgroundColor = [ConsoleColor]::DarkRed
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Red
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
# write # and space
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptHighlightColor
# write user
$user = $sl.CurrentUser
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object " $user" -ForegroundColor $sl.Colors.PromptHighlightColor
# write at (devicename)
$computer = $sl.CurrentHostname
$prompt += Write-Prompt -Object " at" -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object " $computer" -ForegroundColor $sl.Colors.GitDefaultColor
# write in for folder
$prompt += Write-Prompt -Object " in" -ForegroundColor $sl.Colors.PromptForegroundColor
}
# write folder
$dir = Get-FullPath -dir $pwd
$prompt += Write-Prompt -Object " $dir " -ForegroundColor $sl.Colors.AdminIconForegroundColor
# write on (git:branchname status)
$status = Get-VCSStatus
if ($status) {
$sl.GitSymbols.BranchSymbol = ''
$themeInfo = Get-VcsInfo -status ($status)
$prompt += Write-Prompt -Object 'on git:' -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object "$($themeInfo.VcInfo) " -ForegroundColor $themeInfo.BackgroundColor
}
# write virtualenv
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object 'inside env:' -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object "$(Get-VirtualEnvName) " -ForegroundColor $themeInfo.VirtualEnvForegroundColor
}
# write [time]
$timeStamp = Get-Date -Format T
$prompt += Write-Prompt "[$timeStamp]" -ForegroundColor $sl.Colors.PromptForegroundColor
# check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor
}
# check the last command state and indicate if failed
$foregroundColor = $sl.Colors.PromptHighlightColor
If ($lastCommandFailed) {
$foregroundColor = $sl.Colors.CommandFailedIconForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
$prompt += Set-Newline
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $foregroundColor
$prompt += ' '
$prompt
}
function Get-TimeSinceLastCommit {
return (git log --pretty=format:'%cr' -1)
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.StartSymbol = '#'
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x279C)
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta
$sl.Colors.VirtualEnvForegroundColor = [ConsoleColor]::Red
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt = Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor
}
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor
}
$user = $sl.CurrentUser
$lambda = [char]::ConvertFromUtf32(0x000003BB)
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object "$lambda " -ForegroundColor $sl.Colors.PromptForegroundColor
}
# Writes the drive portion
$prompt += Write-Prompt -Object "$(Get-ShortPath -dir $pwd) " -ForegroundColor $sl.Colors.DriveForegroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$prompt += Write-Prompt -Object "git:" -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object "$($themeInfo.VcInfo) " -ForegroundColor $themeInfo.BackgroundColor
}
# write virtualenv
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object 'env:' -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object "$(Get-VirtualEnvName) " -ForegroundColor $themeInfo.VirtualEnvForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkRed
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.WithBackgroundColor = [ConsoleColor]::DarkRed
$sl.Colors.DriveForegroundColor = [ConsoleColor]::DarkRed
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
#$prompt += Write-Prompt -Object ($sl.PromptSymbols.PromptIndicator+" ") -ForegroundColor $sl.Colors.PromptBackgroundColor
#check the last command state and indicate if failed
$promtSymbolColor = [ConsoleColor]::Green
If ($lastCommandFailed) {
$promtSymbolColor = [ConsoleColor]::Red
}
$prompt += Write-Prompt -Object (
[char]::ConvertFromUtf32(0x276F)) -ForegroundColor $sl.Colors.GitNoLocalChangesAndAheadColor
$prompt += Write-Prompt -Object (
[char]::ConvertFromUtf32(0x276F)+" ") -ForegroundColor $promtSymbolColor
# Writes the postfixes to the prompt
$user = $sl.CurrentUser
$prompt += Write-Prompt -Object $user
$prompt += Write-Prompt -Object " :: "
# Writes the drive portion
$drive = $sl.PromptSymbols.HomeSymbol
if ($pwd.Path -ne $HOME) {
$drive = "$(Split-Path -path $pwd -Leaf)"
}
$prompt += Write-Prompt -Object $drive -ForegroundColor $sl.Colors.DriveForegroundColor
$status = Get-VCSStatus
if ($status) {
$prompt += Write-Prompt -Object " git(" -ForegroundColor $sl.Colors.PromptHighlightColor
$prompt += Write-Prompt -Object ($status.Branch) -ForegroundColor $sl.Colors.WithForegroundColor
$prompt += Write-Prompt -Object ")" -ForegroundColor $sl.Colors.PromptHighlightColor
if ($status.Working.Length -gt 0) {
$prompt += Write-Prompt -Object (" "+$sl.PromptSymbols.GitDirtyIndicator) -ForegroundColor $sl.Colors.GitDefaultColor
}
} else {
$prompt += Write-Prompt -Object (" ::") -ForegroundColor $sl.Colors.GitDefaultColor
}
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
$sTime = " $(Get-Date -Format HH:mm)"
$prompt += Write-Prompt -Object $sTime -ForegroundColor $sl.colors.PromptSymbolColor
#$prompt += Set-Newline
$prompt += ' '
$prompt
}
function Get-TimeSinceLastCommit {
return (git log --pretty=format:'%cr' -1)
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = '+'
$sl.PromptSymbols.HomeSymbol = 'š '
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Green
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Blue
$sl.Colors.DriveForegroundColor = [ConsoleColor]::Cyan
$sl.Colors.WithForegroundColor = [ConsoleColor]::Red
$sl.PromptSymbols.GitDirtyIndicator =[char]::ConvertFromUtf32(10007)
$sl.Colors.GitDefaultColor = [ConsoleColor]::Yellow
$sl.Colors.AdminIconForegroundColor = [ConsoleColor]::Blue
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$lastColor = $sl.Colors.PromptBackgroundColor
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$prompt += Set-Newline
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
$user = $sl.CurrentUser
$computer = $sl.CurrentHostname
$pathSymbol = if ($pwd.Path -eq $HOME) { $sl.PromptSymbols.PathHomeSymbol } else { $sl.PromptSymbols.PathSymbol }
$path = $pathSymbol + " " + (Get-FullPath -dir $pwd)
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -ForegroundColor $sl.Colors.VirtualEnvForegroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.VirtualEnvBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
else {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
# Writes the drive portion
$prompt += Write-Prompt -Object "$path " -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$lastColor = $themeInfo.BackgroundColor
$prompt += Write-Prompt -Object $($sl.PromptSymbols.SegmentForwardSymbol) -ForegroundColor $sl.Colors.PromptBackgroundColor -BackgroundColor $lastColor
$prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -BackgroundColor $lastColor -ForegroundColor $sl.Colors.GitForegroundColor
}
# Writes the postfix to the prompt
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor
$timeStamp = Get-Date -Format "hh:mm tt"
$timestamp = " $timeStamp "
if ($host.UI.RawUI.CursorPosition.X + $timestamp.Length + 9 -lt $host.UI.RawUI.WindowSize.Width){
$prompt += Set-CursorForRightBlockWrite -textLength ($timestamp.Length + 9)
$prompt += Write-Prompt -Object $sl.PromptSymbols.Blur1Symbol -ForegroundColor $PromptForegroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.Blur2Symbol -ForegroundColor $PromptForegroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.Blur3Symbol -ForegroundColor $PromptForegroundColor
$prompt += Write-Prompt $timeStamp -ForegroundColor $sl.Colors.GitForegroundColor -BackgroundColor $sl.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ClockSymbol) " -ForegroundColor $sl.Colors.GitForegroundColor -BackgroundColor $sl.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.Blur3Symbol -ForegroundColor $PromptForegroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.Blur2Symbol -ForegroundColor $PromptForegroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.Blur1Symbol -ForegroundColor $PromptForegroundColor
}
$prompt += Set-Newline
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object "[email protected]$computer " -ForegroundColor $sl.Colors.SessionInfoForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
$prompt += Write-Prompt -Object ($sl.PromptSymbols.PromptIndicator) -ForegroundColor $sl.Colors.PromptSymbolColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.StartSymbol = ''
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
$sl.PromptSymbols.Blur1Symbol = [char]::ConvertFromUtf32(0x2591)
$sl.PromptSymbols.Blur2Symbol = [char]::ConvertFromUtf32(0x2592)
$sl.PromptSymbols.Blur3Symbol = [char]::ConvertFromUtf32(0x2593)
$sl.PromptSymbols.ClockSymbol = [char]::ConvertFromUtf32(0xf64f)
$sl.PromptSymbols.PathHomeSymbol = [char]::ConvertFromUtf32(0xf015)
$sl.PromptSymbols.PathSymbol = [char]::ConvertFromUtf32(0xf07c)
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.GitForegroundColor = [ConsoleColor]::Black
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Red
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$lastColor = $sl.Colors.PromptBackgroundColor
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
$user = $sl.CurrentUser
$computer = $sl.CurrentHostname
$path = Get-FullPath -dir $pwd
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object "[email protected]$computer " -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -ForegroundColor $sl.Colors.VirtualEnvForegroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.VirtualEnvBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
else {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
# Writes the drive portion
$prompt += Write-Prompt -Object "$path " -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$lastColor = $themeInfo.BackgroundColor
$prompt += Write-Prompt -Object $($sl.PromptSymbols.SegmentForwardSymbol) -ForegroundColor $sl.Colors.PromptBackgroundColor -BackgroundColor $lastColor
$prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -BackgroundColor $lastColor -ForegroundColor $sl.Colors.GitForegroundColor
}
# Writes the postfix to the prompt
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor
$timeStamp = Get-Date -UFormat %R
$timestamp = "[$timeStamp]"
$prompt += Set-CursorForRightBlockWrite -textLength ($timestamp.Length + 1)
$prompt += Write-Prompt $timeStamp -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += Set-Newline
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
$prompt += Write-Prompt -Object ($sl.PromptSymbols.PromptIndicator) -ForegroundColor $sl.Colors.PromptSymbolColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.StartSymbol = ''
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.GitForegroundColor = [ConsoleColor]::Black
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Red
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
#check the last command state and indicate if failed and change the colors of the arrows
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object (
[char]::ConvertFromUtf32(0x276F)) -ForegroundColor $sl.Colors.WithForegroundColor
$prompt += Write-Prompt -Object (
[char]::ConvertFromUtf32(0x276F) +" ") -ForegroundColor $sl.Colors.WithForegroundColor
}Else{
$prompt += Write-Prompt -Object (
[char]::ConvertFromUtf32(0x276F)) -ForegroundColor $sl.Colors.GitNoLocalChangesAndAheadColor
$prompt += Write-Prompt -Object (
[char]::ConvertFromUtf32(0x276F) +" ") -ForegroundColor $sl.Colors.PromptSymbolColor
}
# Writes the drive portion
$drive = $sl.PromptSymbols.HomeSymbol
if ($pwd.Path -ne $HOME) {
$drive = "$(Split-Path -path $pwd -Leaf)"
}
$prompt += Write-Prompt -Object $drive -ForegroundColor $sl.Colors.DriveForegroundColor
$status = Get-VCSStatus
if ($status) {
$prompt += Write-Prompt -Object " git:(" -ForegroundColor $sl.Colors.PromptHighlightColor
$prompt += Write-Prompt -Object "$($status.Branch)" -ForegroundColor $sl.Colors.WithForegroundColor
$prompt += Write-Prompt -Object ")" -ForegroundColor $sl.Colors.PromptHighlightColor
if ($status.Working.Length -gt 0) {
$prompt += Write-Prompt -Object (" " + $sl.PromptSymbols.GitDirtyIndicator) -ForegroundColor $sl.Colors.GitDefaultColor
}
}
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
$timeStamp = Get-Date -UFormat %R
$clock = [char]::ConvertFromUtf32(0x25F7)
$timestamp = "$clock $timeStamp"
if ($status) {
$timeStamp = Get-TimeSinceLastCommit
}
$prompt += Set-CursorForRightBlockWrite -textLength $timestamp.Length
$prompt += Write-Prompt $timeStamp -ForegroundColor $sl.Colors.DriveForegroundColor
$prompt += Set-Newline
$prompt += Write-Prompt -Object ($sl.PromptSymbols.PromptIndicator) -ForegroundColor $sl.Colors.PromptBackgroundColor
$prompt += ' '
$prompt
}
function Get-TimeSinceLastCommit {
return (git log --pretty=format:'%cr' -1)
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x1F441)
$sl.PromptSymbols.HomeSymbol = [char]::ConvertFromUtf32(0x1F3E0)
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Green
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Blue
$sl.Colors.DriveForegroundColor = [ConsoleColor]::Cyan
$sl.Colors.WithForegroundColor = [ConsoleColor]::Red
$sl.PromptSymbols.GitDirtyIndicator = [char]::ConvertFromUtf32(0x1F4CC)
$sl.Colors.GitDefaultColor = [ConsoleColor]::Yellow
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$adminsymbol = $sl.PromptSymbols.ElevatedSymbol
$venvsymbol = $sl.PromptSymbols.VirtualEnvSymbol
$clocksymbol = $sl.PromptSymbols.ClockSymbol
## Left Part
$prompt = Write-Prompt -Object " $($sl.PromptSymbols.StartSymbol) " -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentSubForwardSymbol) " -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$pathSymbol = if ($pwd.Path -eq $HOME) { $sl.PromptSymbols.PathHomeSymbol } else { $sl.PromptSymbols.PathSymbol }
# Writes the drive portion
$path = $pathSymbol + " " + (Get-FullPath -dir $pwd) + " "
$prompt += Write-Prompt -Object $path -ForegroundColor $sl.Colors.DriveForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentSubForwardSymbol -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -ForegroundColor $themeInfo.BackgroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
If ($with) {
$sWith = " $($with.ToUpper())"
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentSubForwardSymbol -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$prompt += Write-Prompt -Object $sWith -ForegroundColor $sl.Colors.WithForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $sl.Colors.SessionInfoBackgroundColor
###
## Right Part
$rightElements = New-Object 'System.Collections.Generic.List[Tuple[string,ConsoleColor]]'
$login = $sl.CurrentUser
$computer = [System.Environment]::MachineName;
$rightElements.Add([System.Tuple]::Create($sl.PromptSymbols.SegmentBackwardSymbol, $sl.Colors.SessionInfoBackgroundColor))
# List of all right elements
if (Test-VirtualEnv) {
$rightElements.Add([System.Tuple]::Create(" $(Get-VirtualEnvName) $venvsymbol ", $sl.Colors.VirtualEnvForegroundColor))
$rightElements.Add([System.Tuple]::Create($sl.PromptSymbols.SegmentSubBackwardSymbol, $sl.Colors.PromptForegroundColor))
}
if (Test-Administrator) {
$rightElements.Add([System.Tuple]::Create(" $adminsymbol", $sl.Colors.AdminIconForegroundColor))
}
$rightElements.Add([System.Tuple]::Create(" [email protected]$computer ", $sl.Colors.UserForegroundColor))
$rightElements.Add([System.Tuple]::Create($sl.PromptSymbols.SegmentSubBackwardSymbol, $sl.Colors.PromptForegroundColor))
$rightElements.Add([System.Tuple]::Create(" $(Get-Date -Format HH:mm:ss) $clocksymbol ", $sl.Colors.TimestampForegroundColor))
$lengthList = [Linq.Enumerable]::Select($rightElements, [Func[Tuple[string, ConsoleColor], int]] { $args[0].Item1.Length })
$total = [Linq.Enumerable]::Sum($lengthList)
# Transform into total length
$prompt += Set-CursorForRightBlockWrite -textLength $total
# The line head needs special care and is always drawn
$prompt += Write-Prompt -Object $rightElements[0].Item1 -ForegroundColor $sl.Colors.SessionInfoBackgroundColor
for ($i = 1; $i -lt $rightElements.Count; $i++) {
$prompt += Write-Prompt -Object $rightElements[$i].Item1 -ForegroundColor $rightElements[$i].Item2 -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
###
$prompt += Write-Prompt -Object "`r"
$prompt += Set-Newline
# Writes the postfixes to the prompt
$indicatorColor = If ($lastCommandFailed) { $sl.Colors.CommandFailedIconForegroundColor } Else { $sl.Colors.PromptSymbolColor }
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $indicatorColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.StartSymbol = [char]::ConvertFromUtf32(0xe62a)
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
$sl.PromptSymbols.SegmentSubForwardSymbol = [char]::ConvertFromUtf32(0xE0B1)
$sl.PromptSymbols.SegmentBackwardSymbol = [char]::ConvertFromUtf32(0xE0B2)
$sl.PromptSymbols.SegmentSubBackwardSymbol = [char]::ConvertFromUtf32(0xE0B3)
$sl.PromptSymbols.ClockSymbol = [char]::ConvertFromUtf32(0xf64f)
$sl.PromptSymbols.PathHomeSymbol = [char]::ConvertFromUtf32(0xf015)
$sl.PromptSymbols.PathSymbol = [char]::ConvertFromUtf32(0xf07c)
$sl.Colors.PromptBackgroundColor = [ConsoleColor]::DarkGray
$sl.Colors.SessionInfoBackgroundColor = [ConsoleColor]::DarkGray
$sl.Colors.VirtualEnvBackgroundColor = [ConsoleColor]::DarkGray
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Green
$sl.Colors.CommandFailedIconForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.DriveForegroundColor = [ConsoleColor]::Cyan
$sl.Colors.PromptForegroundColor = [ConsoleColor]::Gray
$sl.Colors.SessionInfoForegroundColor = [ConsoleColor]::White
$sl.Colors.WithForegroundColor = [ConsoleColor]::Red
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::Magenta
$sl.Colors.TimestampForegroundColor = [ConsoleColor]::Green
$sl.Colors.UserForegroundColor = [ConsoleColor]::Yellow
$sl.Colors.GitForegroundColor = [ConsoleColor]::White # Just in case...
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
# path
$sPath = "$(Get-FullPath -dir $pwd) "
# check for elevated prompt
$sAdmin = ""
If (Test-Administrator) {
$sAdmin = " $($sl.PromptSymbols.ElevatedSymbol)"
}
# git info
$sVcs = ""
#$vcsInfo = $sl.Colors.DriveForegroundColor
If ($vcsStatus = Get-VCSStatus) {
$vcsInfo = Get-VcsInfo -status ($vcsStatus)
$sVcs = "$($vcsInfo.VcInfo) "
}
# timestamp
$sTime = " $(Get-Date -Format HH:mm:ss)"
# check the last command state and indicate if failed
$sFailed = ""
If ($lastCommandFailed) {
$sFailed = " $($sl.PromptSymbols.FailedCommandSymbol)"
}
# virtualenv
$sVenv = ""
If (Test-VirtualEnv) {
$sVenv = " $(Get-VirtualEnvName)"
}
# with
$sWith = ""
If ($with) {
$sWith = " $($with.ToUpper())"
}
$rightPrompt = "$sFailed$sWith$sVenv$sAdmin$sTime"
$prompt += Set-CursorForRightBlockWrite -textLength $rightPrompt.Length
$prompt += Write-Prompt -Object $sFailed -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor
$prompt += Write-Prompt -Object $sWith -ForegroundColor $sl.Colors.WithForegroundColor
$prompt += Write-Prompt -Object $sVenv -ForegroundColor $sl.Colors.VirtualEnvForegroundColor
$prompt += Write-Prompt -Object $sAdmin -ForegroundColor $sl.Colors.AdminIconForegroundColor
$prompt += Write-Prompt -Object $sTime -ForegroundColor $sl.colors.TimestampForegroundColor
$prompt += Write-Prompt -Object "`r"
$prompt += Write-Prompt -Object $sPath -ForegroundColor $sl.Colors.DriveForegroundColor
$prompt += Write-Prompt -Object $sVcs -ForegroundColor $vcsInfo.BackgroundColor
If ($sl.DoubleCommandLine) {
$prompt += Set-Newline
}
# Writes the postfixes to the prompt
$indicatorColor = If ($lastCommandFailed) { $sl.Colors.CommandFailedIconForegroundColor } Else { $sl.Colors.PromptSymbolColor }
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $indicatorColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Green
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::Magenta
$sl.Colors.TimestampForegroundColor = [ConsoleColor]::DarkCyan
$sl | Add-Member -NotePropertyName DoubleCommandLine -NotePropertyValue 0 -Force
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$adminsymbol = $sl.PromptSymbols.ElevatedSymbol
$venvsymbol = $sl.PromptSymbols.VirtualEnvSymbol
$lastColor = $sl.Colors.SessionInfoBackgroundColor
$login = $sl.CurrentUser
$computer = (Get-Culture).TextInfo.ToTitleCase([System.Environment]::MachineName.ToLower());
if ($IsLinux) { $iconhex = 0xf17c }
elseif ($IsMacOS) { $iconhex = 0xf302 }
else { $iconhex = 0xe70f }
## Left Part
$prompt = Write-Prompt -Object "āā" -ForegroundColor $sl.Colors.PromptSymbolColor
$prompt += Write-Prompt -Object " $([char]::ConvertFromUtf32($iconhex))" -ForegroundColor $sl.Colors.StartForegroundColor
$prompt += Write-Prompt -Object " $($sl.PromptSymbols.SegmentSubForwardSymbol)" -ForegroundColor $sl.Colors.UserForegroundColor
$prompt += Write-Prompt -Object " [email protected]$computer " -ForegroundColor $sl.Colors.UserForegroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.PromptSymbolColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$pathSymbol = if ($pwd.Path -eq $HOME) { $sl.PromptSymbols.PathHomeSymbol } else { $sl.PromptSymbols.PathSymbol }
# Writes the drive portion
$path = $pathSymbol + " " + (Get-ShortPath -dir $pwd) + " "
$prompt += Write-Prompt -Object $path -ForegroundColor $sl.Colors.DriveForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$lastColor = $themeInfo.BackgroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $themeInfo.BackgroundColor
$prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $themeInfo.BackgroundColor
}
If ($with) {
$sWith = " $($with.ToUpper())"
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentSubForwardSymbol -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$prompt += Write-Prompt -Object $sWith -ForegroundColor $sl.Colors.WithForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor
###
## Right Part
$rightElements = New-Object 'System.Collections.Generic.List[Tuple[string,ConsoleColor]]'
$rightElements.Add([System.Tuple]::Create($sl.PromptSymbols.SegmentBackwardSymbol, $sl.Colors.StatsInfoBackgroundColor))
# List of all right elements
if (Test-VirtualEnv) {
$rightElements.Add([System.Tuple]::Create(" $(Get-VirtualEnvName) $venvsymbol ", $sl.Colors.VirtualEnvForegroundColor))
$rightElements.Add([System.Tuple]::Create($sl.PromptSymbols.SegmentSubBackwardSymbol, $sl.Colors.PromptForegroundColor))
}
if (Test-Administrator) {
$rightElements.Add([System.Tuple]::Create(" $adminsymbol", $sl.Colors.AdminIconForegroundColor))
}
$battery = Get-BatteryInfo
if ($battery) {
$rightElements.Add([System.Tuple]::Create(" $battery ", $sl.Colors.PromptForegroundColor))
$rightElements.Add([System.Tuple]::Create($sl.PromptSymbols.SegmentSubBackwardSymbol, $sl.Colors.PromptForegroundColor))
}
# Update the clock icon based on time
[int]$hour = Get-Date -UFormat %I
switch ($hour) {
1 { $clockhex = 0xe382 }
2 { $clockhex = 0xe383 }
3 { $clockhex = 0xe384 }
4 { $clockhex = 0xe385 }
5 { $clockhex = 0xe386 }
6 { $clockhex = 0xe387 }
7 { $clockhex = 0xe388 }
8 { $clockhex = 0xe389 }
9 { $clockhex = 0xe38a }
10 { $clockhex = 0xe38b }
11 { $clockhex = 0xe38c }
Default { $clockhex = 0xe381 }
}
$clocksymbol = [char]::ConvertFromUtf32($clockhex)
$rightElements.Add([System.Tuple]::Create(" $(Get-Date -Format HH:mm:ss) $clocksymbol ", $sl.Colors.PromptForegroundColor))
$lengthList = [Linq.Enumerable]::Select($rightElements, [Func[Tuple[string, ConsoleColor], int]] { $args[0].Item1.Length })
$total = [Linq.Enumerable]::Sum($lengthList)
# Transform into total length
$prompt += Set-CursorForRightBlockWrite -textLength $total
# The line head needs special care and is always drawn
$prompt += Write-Prompt -Object $rightElements[0].Item1 -ForegroundColor $sl.Colors.StatsInfoBackgroundColor
for ($i = 1; $i -lt $rightElements.Count; $i++) {
$prompt += Write-Prompt -Object $rightElements[$i].Item1 -ForegroundColor $rightElements[$i].Item2 -BackgroundColor $sl.Colors.StatsInfoBackgroundColor
}
###
$prompt += Write-Prompt -Object "`r"
$prompt += Set-Newline
# Writes the postfixes to the prompt
$indicatorColor = If ($lastCommandFailed) { $sl.Colors.CommandFailedIconForegroundColor } Else { $sl.Colors.PromptSymbolColor }
$prompt += Write-Prompt -Object "āā" -ForegroundColor $indicatorColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
$sl.PromptSymbols.SegmentSubForwardSymbol = [char]::ConvertFromUtf32(0xE0B1)
$sl.PromptSymbols.SegmentBackwardSymbol = [char]::ConvertFromUtf32(0xE0B2)
$sl.PromptSymbols.SegmentSubBackwardSymbol = [char]::ConvertFromUtf32(0xE0B3)
$sl.PromptSymbols.PathHomeSymbol = [char]::ConvertFromUtf32(0xf015)
$sl.PromptSymbols.PathSymbol = [char]::ConvertFromUtf32(0xf07c)
$sl.Colors.PromptBackgroundColor = [ConsoleColor]::DarkGray
$sl.Colors.SessionInfoBackgroundColor = [ConsoleColor]::DarkBlue
$sl.Colors.StatsInfoBackgroundColor = [ConsoleColor]::Black
$sl.Colors.VirtualEnvBackgroundColor = [ConsoleColor]::DarkGray
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Blue
$sl.Colors.CommandFailedIconForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.DriveForegroundColor = [ConsoleColor]::Cyan
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.SessionInfoForegroundColor = [ConsoleColor]::White
$sl.Colors.StartForegroundColor = [ConsoleColor]::Blue
$sl.Colors.WithForegroundColor = [ConsoleColor]::Red
$sl.Colors.VirtualEnvForegroundColor = [ConsoleColor]::Magenta
$sl.Colors.UserForegroundColor = [ConsoleColor]::White
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$lastColor = $sl.Colors.PromptBackgroundColor
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
$user = $sl.CurrentUser
$computer = [System.Environment]::MachineName
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object "[email protected]$computer " -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -ForegroundColor $sl.Colors.VirtualEnvForegroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.VirtualEnvBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
else {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
# Writes the drive portion
$path = (Get-FullPath -dir $pwd).Replace('\', ' ' + [char]::ConvertFromUtf32(0xE0B1) + ' ') + ' '
$prompt += Write-Prompt -Object $path -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$lastColor = $themeInfo.BackgroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $sl.Colors.PromptBackgroundColor -BackgroundColor $lastColor
$prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -BackgroundColor $lastColor -ForegroundColor $sl.Colors.GitForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor -BackgroundColor $sl.Colors.WithBackgroundColor
$prompt += Write-Prompt -Object " $($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
$lastColor = $sl.Colors.WithBackgroundColor
}
# Writes the postfix to the prompt
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
$sl.Colors.SessionInfoBackgroundColor = [ConsoleColor]::DarkGray
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.GitForegroundColor = [ConsoleColor]::DarkGray
$sl.Colors.WithForegroundColor = [ConsoleColor]::White
$sl.Colors.WithBackgroundColor = [ConsoleColor]::DarkRed
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Red
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$lastColor = $sl.Colors.PromptBackgroundColor
$authorityStatus = ((Invoke-CimMethod -InputObject $(Get-CimInstance Win32_Process -Filter "Handle=$PID") -MethodName GetOwner).User) -eq 'SYSTEM'
# identify background colors for administrative rights
# declare the colors
$rootBackground = [ConsoleColor]::Magenta
$rootForeground = [ConsoleColor]::White
$reguserBackground = [ConsoleColor]::Blue
$reguserForeground = [ConsoleColor]::White
$authorityForeground = [ConsoleColor]::White
$authorityBackground = [ConsoleColor]::Red
# make it work
If ($authorityStatus) {
$promptTagBackground = $authorityBackground
$promptTagForeground = $authorityForeground
}
else {
If (Test-Administrator) {
$promptTagBackground = $rootBackground
$rootForeground = $rootForeground
}
else {
$promptTagBackground = $reguserBackground
$promptTagForeground = $reguserForeground
}
}
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
$user = $sl.CurrentUser
$computer = [System.Environment]::MachineName
if ($authorityStatus) {
$prompt += Write-Prompt -Object "$computer" -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
else {
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object "[email protected]$computer" -ForegroundColor $sl.Colors.SessionInfoForegroundColor -BackgroundColor $sl.Colors.SessionInfoBackgroundColor
}
}
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.VirtualEnvSymbol) $(Get-VirtualEnvName) " -ForegroundColor $sl.Colors.VirtualEnvForegroundColor -BackgroundColor $sl.Colors.VirtualEnvBackgroundColor
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.VirtualEnvBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
else {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $sl.Colors.SessionInfoBackgroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
}
# Writes the drive portion
$path = (Get-ShortPath -dir $pwd).Replace('\', ' ' + [char]::ConvertFromUtf32(0xE0B1) + ' ') + ' '
$prompt += Write-Prompt -Object $path -ForegroundColor $sl.Colors.PromptForegroundColor -BackgroundColor $sl.Colors.PromptBackgroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$lastColor = $themeInfo.BackgroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $sl.Colors.PromptBackgroundColor -BackgroundColor $lastColor
$prompt += Write-Prompt -Object " $($themeInfo.VcInfo) " -BackgroundColor $lastColor -ForegroundColor $sl.Colors.GitForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $lastColor -BackgroundColor $sl.Colors.WithBackgroundColor
$prompt += Write-Prompt -Object " $($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
$lastColor = $sl.Colors.WithBackgroundColor
}
If ($lastCommandFailed) {
$errsign = "ERROR".Replace('\', ' ' + [char]::ConvertFromUtf32(0xE0B1) + ' ') + ' '
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $lastColor -BackgroundColor $errBackground
$prompt += Write-Prompt -Object $errsign -ForegroundColor $errForeground -BackgroundColor $errBackground
$lastColor = $errBackground
$promptTagBackgroundStatusErrCheck = $errBackground
}
else {
$promptTagBackgroundStatusErrCheck = $promptTagBackground
}
If ($authorityStatus) {
$authoritysign = "@".Replace('\', ' ' + [char]::ConvertFromUtf32(0xE0B1) + ' ') + ' '
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $lastColor -BackgroundColor $promptTagBackgroundStatusErrCheck
$prompt += Write-Prompt -Object $authoritysign -ForegroundColor $promptTagForeground -BackgroundColor $promptTagBackgroundStatusErrCheck
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $promptTagBackgroundStatusErrCheck -BackgroundColor $sl.Colors.SessionInfoForegroundColor
}
else {
If (Test-Administrator) {
$rootsign = "#".Replace('\', ' ' + [char]::ConvertFromUtf32(0xE0B1) + ' ') + ' '
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $lastColor -BackgroundColor $promptTagBackgroundStatusErrCheck
$prompt += Write-Prompt -Object $rootsign -ForegroundColor $promptTagForeground -BackgroundColor $promptTagBackgroundStatusErrCheck
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $promptTagBackgroundStatusErrCheck -BackgroundColor $sl.Colors.SessionInfoForegroundColor
}
else {
$norootsign = "$".Replace('\', ' ' + [char]::ConvertFromUtf32(0xE0B1) + ' ') + ' '
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.SegmentForwardSymbol) " -ForegroundColor $lastColor -BackgroundColor $promptTagBackgroundStatusErrCheck
$prompt += Write-Prompt -Object $norootsign -ForegroundColor $promptTagForeground -BackgroundColor $promptTagBackgroundStatusErrCheck
$prompt += Write-Prompt -Object $sl.PromptSymbols.SegmentForwardSymbol -ForegroundColor $promptTagBackgroundStatusErrCheck -BackgroundColor $sl.Colors.SessionInfoForegroundColor
}
}
# Writes the postfix to the prompt
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.SegmentForwardSymbol = [char]::ConvertFromUtf32(0xE0B0)
$sl.Colors.SessionInfoBackgroundColor = [ConsoleColor]::Cyan
$sl.Colors.SessionInfoForegroundColor = [ConsoleColor]::Black
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.GitForegroundColor = [ConsoleColor]::Black
$sl.Colors.WithForegroundColor = [ConsoleColor]::White
$sl.Colors.WithBackgroundColor = [ConsoleColor]::DarkRed
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Red
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::White
$errForeground = [ConsoleColor]::White
$errBackground = [ConsoleColor]::DarkRed
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt = Write-Prompt -Object "Don't Panic!" -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor
}
$prompt += Set-Newline
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor
}
$status = Get-VCSStatus
if ($status) {
$prompt += Write-Prompt -Object "$($status.Branch)$([char]::ConvertFromUtf32(0xE0A0)) " -ForegroundColor $themeInfo.BackgroundColor
}
# write virtualenv
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object "$(Get-VirtualEnvName)" -ForegroundColor $themeInfo.VirtualEnvForegroundColor
}
# Writes the drive portion
$prompt += Write-Prompt -Object " $(Get-FullPath -dir $pwd)" -ForegroundColor $sl.Colors.DriveForegroundColor
# Writes the postfixes to the prompt
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.DriveForegroundColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
#check the last command state and indicate if failed
$promtSymbolColor = $sl.Colors.PromptSymbolColor
If ($lastCommandFailed) {
$promtSymbolColor = $sl.Colors.WithForegroundColor
}
# Writes the drive portion
$drive = Get-FullPath -dir $pwd
$prompt += Write-Prompt -Object $drive -ForegroundColor $sl.Colors.DriveForegroundColor
$prompt += Write-Prompt -Object ' '
$status = Get-VCSStatus
if ($status) {
$prompt += Write-Prompt -Object "$($status.Branch)" -ForegroundColor $sl.Colors.WithForegroundColor
if ($status.Working.Length -gt 0) {
$prompt += Write-Prompt -Object (" " + $sl.PromptSymbols.GitDirtyIndicator) -ForegroundColor $sl.Colors.GitDefaultColor
}
}
# New line
$prompt += Set-Newline
# Writes the postfixes to the prompt
$prompt += Write-Prompt -Object ($sl.PromptSymbols.PromptIndicator) -ForegroundColor $promtSymbolColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276f)
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Green
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Blue
$sl.Colors.DriveForegroundColor = [ConsoleColor]::Cyan
$sl.Colors.WithForegroundColor = [ConsoleColor]::Red
$sl.PromptSymbols.GitDirtyIndicator = [char]::ConvertFromUtf32(10007)
$sl.Colors.GitDefaultColor = [ConsoleColor]::Yellow
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptForegroundColor
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor
}
$drive = $sl.PromptSymbols.HomeSymbol
if ($pwd.Path -ne $HOME) {
$drive = "$(Split-Path -path $pwd -Leaf)"
}
$prompt += Write-Prompt -Object $drive -ForegroundColor $sl.Colors.PromptForegroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$lastColor = $themeInfo.BackgroundColor
$prompt += Write-Prompt -Object " ::" -ForegroundColor $sl.Colors.AccentColor
$prompt += Write-Prompt -Object " $($status.Branch)" -ForegroundColor $lastColor
}
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object " $($sl.PromptSymbols.FailedCommandSymbol)" -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor
}
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object " $($sl.PromptSymbols.VirtualEnvSymbol)" -ForegroundColor $sl.Colors.AccentColor
$prompt += Write-Prompt -Object " $(Get-VirtualEnvName)" -ForegroundColor $sl.Colors.VirtualEnvForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object " *" -ForegroundColor $sl.Colors.AccentColor
$prompt += Write-Prompt -Object " $($with.ToUpper())" -ForegroundColor $sl.Colors.WithForegroundColor
}
$prompt += Write-Prompt -Object (" " + $sl.PromptSymbols.PromptIndicator) -ForegroundColor $sl.Colors.AccentColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.StartSymbol = ''
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276f)
$sl.Colors.PromptForegroundColor = [ConsoleColor]::Cyan
$sl.Colors.WithForegroundColor = [ConsoleColor]::Red
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Cyan
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.VirtualEnvBackgroundColor = [System.ConsoleColor]::Magenta
$sl.Colors.VirtualEnvForegroundColor = [System.ConsoleColor]::Magenta
$sl.Colors.AccentColor = [System.ConsoleColor]::DarkGray
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
#check the last command state and indicate if failed
$promtSymbolColor = $sl.Colors.PromptSymbolColor
If ($lastCommandFailed) {
$promtSymbolColor = $sl.Colors.WithForegroundColor
}
#check the python virtual environment
If (Test-VirtualEnv) {
$prompt += Write-Prompt -Object ("(" + $(Get-VirtualEnvName) + ") ")
}
# Writes the postfixes to the prompt
$prompt += Write-Prompt -Object ($sl.PromptSymbols.PromptIndicator + " ") -ForegroundColor $promtSymbolColor
# Writes the drive portion
$drive = $sl.PromptSymbols.HomeSymbol
if ($pwd.Path -ne $HOME) {
$drive = "$(Split-Path -path $pwd -Leaf)"
}
$prompt += Write-Prompt -Object $drive -ForegroundColor $sl.Colors.DriveForegroundColor
$status = Get-VCSStatus
if ($status) {
$prompt += Write-Prompt -Object " git:(" -ForegroundColor $sl.Colors.PromptHighlightColor
$prompt += Write-Prompt -Object "$($status.Branch)" -ForegroundColor $sl.Colors.WithForegroundColor
$prompt += Write-Prompt -Object ")" -ForegroundColor $sl.Colors.PromptHighlightColor
if ($status.Working.Length -gt 0) {
$prompt += Write-Prompt -Object (" " + $sl.PromptSymbols.GitDirtyIndicator) -ForegroundColor $sl.Colors.GitDefaultColor
}
}
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x279C)
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Green
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Blue
$sl.Colors.DriveForegroundColor = [ConsoleColor]::Cyan
$sl.Colors.WithForegroundColor = [ConsoleColor]::Red
$sl.PromptSymbols.GitDirtyIndicator = [char]::ConvertFromUtf32(10007)
$sl.Colors.GitDefaultColor = [ConsoleColor]::Yellow
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
#check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt = Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor
}
#check for elevated prompt
If (Test-Administrator) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.ElevatedSymbol) " -ForegroundColor $sl.Colors.AdminIconForegroundColor
}
$user = $sl.CurrentUser
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object "$user " -ForegroundColor $sl.Colors.PromptForegroundColor
}
# Writes the drive portion
$prompt += Write-Prompt -Object "$(Get-ShortPath -dir $pwd) " -ForegroundColor $sl.Colors.DriveForegroundColor
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$prompt += Write-Prompt -Object "git:" -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object "$($themeInfo.VcInfo) " -ForegroundColor $themeInfo.BackgroundColor
}
# write virtualenv
if (Test-VirtualEnv) {
$prompt += Write-Prompt -Object 'env:' -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object "$(Get-VirtualEnvName) " -ForegroundColor $themeInfo.VirtualEnvForegroundColor
}
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
# Writes the postfixes to the prompt
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.AdminIconForegroundColor
$prompt += Write-Prompt -Object $sl.PromptSymbols.PromptIndicator -ForegroundColor $sl.Colors.GitNoLocalChangesAndAheadColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x276F)
$sl.Colors.PromptForegroundColor = [ConsoleColor]::White
$sl.Colors.PromptSymbolColor = [ConsoleColor]::White
$sl.Colors.PromptHighlightColor = [ConsoleColor]::DarkBlue
$sl.Colors.WithForegroundColor = [ConsoleColor]::DarkRed
$sl.Colors.WithBackgroundColor = [ConsoleColor]::Magenta
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
#check the last command state and indicate if failed and change the colors of the arrows
$dir = Get-FullPath -dir $pwd
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object $dir -ForegroundColor $sl.Colors.WithForegroundColor
}else{
$prompt += Write-Prompt -Object $dir -ForegroundColor $sl.Colors.DriveForegroundColor
}
# Writes the drive portion
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$info = "$($themeInfo.VcInfo)".Split(" ")[1].TrimStart()
$prompt += Write-Prompt -Object " on " -ForegroundColor $sl.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object "$($sl.GitSymbols.BranchSymbol+' ')" -ForegroundColor $sl.Colors.GitDefaultColor
$prompt += Write-Prompt -Object "$($status.Branch)" -ForegroundColor $sl.Colors.GitDefaultColor
$prompt += Write-Prompt -Object " [$($info)]" -ForegroundColor $sl.Colors.PromptHighlightColor
$filename = 'package.json'
if (Test-Path -path $filename) {
$prompt += Write-Prompt -Object (" via node") -ForegroundColor $sl.Colors.PromptSymbolColor
}
}
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
$prompt+= Set-Newline
$prompt += Write-Prompt -Object ($sl.PromptSymbols.PromptIndicator) -ForegroundColor $sl.Colors.PromptSymbolColor
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.GitSymbols.BranchSymbol = [char]::ConvertFromUtf32(0xE0A0)
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x279C)
$sl.PromptSymbols.HomeSymbol = '~'
$sl.PromptSymbols.GitDirtyIndicator =[char]::ConvertFromUtf32(10007)
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Green
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Blue
$sl.Colors.DriveForegroundColor = [ConsoleColor]::Cyan
$sl.Colors.WithForegroundColor = [ConsoleColor]::Red
$sl.Colors.GitDefaultColor = [ConsoleColor]::Yellow
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$user = $s1.CurrentUser
$prompt = Write-Prompt -Object "$user " -ForegroundColor $s1.Colors.PromptForegroundColor
$prompt += Write-Prompt -Object ":: " -ForegroundColor $s1.Colors.AdminIconForegroundColor
$prompt += Write-Prompt -Object "$(Get-FullPath -dir $pwd) " -ForegroundColor $s1.Colors.DriveForegroundColor
$status = Get-VCSStatus
if ($status) {
$gitbranchpre = [char]::ConvertFromUtf32(0x003c)
$gitbranchpost = [char]::ConvertFromUtf32(0x003e)
$gitinfo = get-vcsinfo -status $status
$prompt += Write-Prompt -Object "$gitbranchpre$($gitinfo.vcinfo)$gitbranchpost " -ForegroundColor $($gitinfo.backgroundcolor)
}
$prompt += Write-Prompt -Object $s1.PromptSymbols.PromptIndicator -ForegroundColor $s1.Colors.AdminIconForegroundColor
$prompt += ' '
$prompt
}
$s1 = $global:ThemeSettings
$s1.GitSymbols.BranchIdenticalStatusToSymbol = ""
$s1.GitSymbols.BranchSymbol = ""
$s1.GitSymbols.BranchUntrackedSymbol = "*"
$s1.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x00BB)
# Colors
$s1.Colors.PromptForegroundColor = [ConsoleColor]::White
$s1.Colors.AdminIconForegroundColor = [ConsoleColor]::Blue
$s1.Colors.DriveForegroundColor = [ConsoleColor]::Green
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
# check the last command state and indicate if failed
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object "$($sl.PromptSymbols.FailedCommandSymbol) " -ForegroundColor $sl.Colors.CommandFailedIconForegroundColor
}
# write # and space
$prompt = Write-Prompt -Object $sl.PromptSymbols.StartSymbol -ForegroundColor $sl.Colors.PromptSymbolColor
# write user and host
$user = $sl.CurrentUser
if (Test-NotDefaultUser($user)) {
$prompt += Write-Prompt -Object " $user" -ForegroundColor $sl.Colors.PromptHighlightColor
# write at (devicename)
$computer = $sl.CurrentHostname
$prompt += Write-Prompt -Object " at" -ForegroundColor $foregroundColor
$prompt += Write-Prompt -Object " $computer" -ForegroundColor $sl.Colors.PromptForegroundColor
# write in for folder
$prompt += Write-Prompt -Object " in" -ForegroundColor $foregroundColor
}
# write folder
$dir = Get-FullPath -dir $pwd
$prompt += Write-Prompt -Object " $dir " -ForegroundColor $sl.Colors.GitDefaultColor
# write on (git:branchname status)
$status = Get-VCSStatus
if ($status) {
$themeInfo = Get-VcsInfo -status ($status)
$prompt += Write-Prompt -Object 'on git:' -ForegroundColor $foregroundColor
$prompt += Write-Prompt -Object "$($themeInfo.VcInfo) " -ForegroundColor $sl.Colors.GitForegroundColor
}
# write [time]
$timeStamp = Get-Date -Format T
$prompt += Write-Prompt "[$timeStamp]" -ForegroundColor $foregroundColor
# new line
$prompt += Set-Newline
if (Test-Administrator) {
$prompt += Write-Prompt -Object ($sl.PromptSymbols.ElevatedSymbol + " ") -ForegroundColor $sl.Colors.AdminIconForegroundColor
}
else{
$prompt += Write-Prompt -Object ($sl.PromptSymbols.PromptIndicator + " ") -ForegroundColor $sl.Colors.PromptSymbolColor
}
}
$sl = $global:ThemeSettings # local settings
$sl.PromptSymbols.StartSymbol = '#'
$sl.PromptSymbols.PromptIndicator = '%'
$sl.PromptSymbols.ElevatedSymbol = '$'
$sl.GitSymbols.BranchSymbol = ''
$sl.GitSymbols.BranchUntrackedSymbol = 'x'
$sl.GitSymbols.BranchIdenticalStatusToSymbol = 'o'
$sl.PromptSymbols.FailedCommandSymbol = '?'
# for dark theme
$sl.Colors.AdminIconForegroundColor = [ConsoleColor]::Red
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Blue
$sl.Colors.PromptForegroundColor = [ConsoleColor]::Green
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Cyan
$sl.Colors.GitDefaultColor = [ConsoleColor]::Yellow
$sl.Colors.GitForegroundColor = [ConsoleColor]::Cyan
# inspired by ys themeļ¼ not to use special characters (powerline fonts).
# >[https://blog.ysmood.org/my-ys-terminal-theme/]()
#requires -Version 2 -Modules posh-git
function Write-Theme {
param(
[bool]
$lastCommandFailed,
[string]
$with
)
$user=$sl.CurrentUser
$prompt+= Write-Prompt -Object ('@'+$user) -ForegroundColor $sl.Colors.WithForegroundColor
#check the last command state and indicate if failed and change the colors of the arrows
If ($lastCommandFailed) {
$prompt += Write-Prompt -Object (' '+$sl.PromptSymbols.PromptIndicator+' ') -ForegroundColor $sl.Colors.WithForegroundColor
}else{
$prompt += Write-Prompt -Object (' '+$sl.PromptSymbols.PromptIndicator+' ') -ForegroundColor $sl.Colors.PromptSymbolColor
}
# Writes the drive portion
$drive = $sl.PromptSymbols.HomeSymbol
if ($pwd.Path -ne $HOME) {
$drive = "$(Split-Path -path $pwd -Leaf)"
}
$prompt += Write-Prompt -Object $drive -ForegroundColor $sl.Colors.DriveForegroundColor
$status = Get-VCSStatus
if ($status) {
$prompt += Write-Prompt -Object " git(" -ForegroundColor $sl.Colors.PromptHighlightColor
$prompt += Write-Prompt -Object "$($status.Branch)" -ForegroundColor $sl.Colors.GitDefaultColor
$prompt += Write-Prompt -Object ")" -ForegroundColor $sl.Colors.PromptHighlightColor
if ($status.Working.Length -gt 0) {
$prompt += Write-Prompt -Object (" " + $sl.PromptSymbols.GitDirtyIndicator) -ForegroundColor $sl.Colors.PromptSymbolColor
}
}
if ($with) {
$prompt += Write-Prompt -Object "$($with.ToUpper()) " -BackgroundColor $sl.Colors.WithBackgroundColor -ForegroundColor $sl.Colors.WithForegroundColor
}
$prompt += ' '
$prompt
}
$sl = $global:ThemeSettings #local settings
$sl.PromptSymbols.PromptIndicator = [char]::ConvertFromUtf32(0x279C)
$sl.PromptSymbols.HomeSymbol = '~'
$sl.PromptSymbols.GitDirtyIndicator =[char]::ConvertFromUtf32(10007)
$sl.Colors.PromptSymbolColor = [ConsoleColor]::Green
$sl.Colors.PromptHighlightColor = [ConsoleColor]::Blue
$sl.Colors.DriveForegroundColor = [ConsoleColor]::Cyan
$sl.Colors.WithForegroundColor = [ConsoleColor]::Red
$sl.Colors.GitDefaultColor = [ConsoleColor]::Yellow
Log in or click on link to see number of positives.
- oh-my-posh.2.0.496.nupkg (aa88027b073f) - ## / 64
In cases where actual malware is found, the packages are subject to removal. Software sometimes has false positives. Moderators do not necessarily validate the safety of the underlying software, only that a package retrieves software from the official distribution point and/or validate embedded software against official distribution point (where distribution rights allow redistribution).
Chocolatey Pro provides runtime protection from possible malware.
Version | Downloads | Last Updated | Status |
---|---|---|---|
Oh-My-Posh 2.0.496 | 882 | Sunday, January 10, 2021 | Approved |
Oh-My-Posh 2.0.492 | 534 | Thursday, December 10, 2020 | Approved |
Oh-My-Posh 2.0.487 | 988 | Friday, October 2, 2020 | Approved |
Oh-My-Posh 2.0.478 | 214 | Friday, September 25, 2020 | Approved |
Oh-My-Posh 2.0.476 | 148 | Tuesday, September 22, 2020 | Approved |
Oh-My-Posh 2.0.472 | 255 | Tuesday, September 15, 2020 | Approved |
Oh-My-Posh 2.0.468 | 425 | Thursday, August 27, 2020 | Approved |
Oh-My-Posh 2.0.465 | 364 | Wednesday, August 12, 2020 | Approved |
Oh-My-Posh 2.0.459 | 50 | Tuesday, August 11, 2020 | Approved |
Oh-My-Posh 2.0.449 | 358 | Friday, July 24, 2020 | Approved |
Oh-My-Posh 2.0.443 | 255 | Friday, July 3, 2020 | Approved |
Oh-My-Posh 2.0.440 | 468 | Friday, June 5, 2020 | Approved |
Oh-My-Posh 2.0.412 | 348 | Thursday, April 23, 2020 | Approved |
Oh-My-Posh 2.0.399 | 602 | Friday, March 13, 2020 | Approved |
Oh-My-Posh 2.0.385 | 275 | Friday, February 21, 2020 | Approved |
Oh-My-Posh 2.0.381 | 172 | Wednesday, February 5, 2020 | Approved |
Oh-My-Posh 2.0.379 | 133 | Sunday, February 2, 2020 | Approved |
Oh-My-Posh 2.0.374 | 45 | Saturday, February 1, 2020 | Approved |
Oh-My-Posh 2.0.371 | 68 | Friday, January 31, 2020 | Approved |
Oh-My-Posh 2.0.342 | 280 | Saturday, December 7, 2019 | Approved |
Oh-My-Posh 2.0.332 | 52 | Thursday, November 28, 2019 | Approved |
Oh-My-Posh 2.0.311 | 285 | Saturday, November 9, 2019 | Approved |
This package has no dependencies.
Ground Rules:
- This discussion is only about Oh-My-Posh and the Oh-My-Posh package. If you have feedback for Chocolatey, please contact the Google Group.
- This discussion will carry over multiple versions. If you have a comment about a particular version, please note that in your comments.
- The maintainers of this Chocolatey Package will be notified about new comments that are posted to this Disqus thread, however, it is NOT a guarantee that you will get a response. If you do not hear back from the maintainers after posting a message below, please follow up by using the link on the left side of this page or follow this link to contact maintainers. If you still hear nothing back, please follow the package triage process.
- Tell us what you love about the package or Oh-My-Posh, or tell us what needs improvement.
- Share your experiences with the package, or extra configuration or gotchas that you've found.
- If you use a url, the comment will be flagged for moderation until you've been whitelisted. Disqus moderated comments are approved on a weekly schedule if not sooner. It could take between 1-5 days for your comment to show up.