Skip to content

A prompt theming engine for Powershell running in ConEmu

License

Notifications You must be signed in to change notification settings

lostpg/oh-my-posh

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

oh-my-posh

Build status Gitter

Table of Contents

About -----

A theme engine for Powershell in ConEmu inspired by the work done by Chris Benti on PS-Config. And Oh-My-ZSH on OSX and Linux (hence the name) More information about why I made this can be found on my blog.

Theme

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 ConEmu to have a brilliant terminal experience on Windows. You can install it using Chocolatey :

choco install ConEmu

The fonts I use are Powerline fonts, there is a great repository containing them and a .ps1 file to install. Or, could absuse PsGet and install them:

Install-Module -ModuleUrl https://github.com/powerline/fonts/archive/master.zip

I use Meslo LG M for Powerline in my ConEmu setup together with custom colors You can find my theme here.

Installation

PsGet

Use PsGet to install oh-my-posh:

Install-Module oh-my-posh

PowerShell Gallery

Use the Powershell Gallery to install posh-git and oh-my-posh:

Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
Configuration

List the current configuration:

$ThemeSettings

Theme

You can tweak the settings by manipulating $ThemeSettings. This example allows you to tweak the branch symbol using a unicode character:

$ThemeSettings.GitSymbols.BranchSymbol = [char]::ConvertFromUtf32(0xE0A0)

Also do not forget the Posh-Git settings itself (enable the stash indication for example):

$GitPromptSettings
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.

Set-Theme paradox

Show-ThemeColors: display the colors used by the theme

Theme

Show-Colors: display colors configured in ConEmu

Theme

Themes

Agnoster

Theme

Paradox

Theme

Sorin

Theme

Darkblood

Theme

Avit

Theme

Honukai

Theme

Fish

Theme

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:

#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-Drive, Get-ShortPath, Set-CursorForRightBlockWrite, Save-CursorPosition, Pop-CursorPosition, Set-CursorUp or add your own logic completely. To test the output in ConEmu, just switch to your theme:

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!

Based on work by

About

A prompt theming engine for Powershell running in ConEmu

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PowerShell 100.0%