Downloads:

47,587

Downloads of v 3.180.1:

2,447

Last Update:

10 Sep 2021

Package Maintainer(s):

Software Author(s):

  • JanDeDobbeleer

Tags:

powershell oh-my-posh posh conemu

Oh-My-Posh

This is not the latest version of Oh-My-Posh available.

  • 1
  • 2
  • 3

3.180.1 | Updated: 10 Sep 2021

Downloads:

47,587

Downloads of v 3.180.1:

2,447

Maintainer(s):

Software Author(s):

  • JanDeDobbeleer

  • 1
  • 2
  • 3
Oh-My-Posh 3.180.1

This is not the latest version of Oh-My-Posh available.

  • 1
  • 2
  • 3

All Checks are Passing

3 Passing Tests


Validation Testing Passed


Verification Testing Passed

Details

Scan Testing Successful:

No detections found in any package files

Details

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

  • 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://community.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

3. Enter your internal repository url

(this should look similar to https://community.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: 3.180.1
    source: STEP 3 URL

See docs at https://docs.ansible.com/ansible/latest/modules/win_chocolatey_module.html.


chocolatey_package 'oh-my-posh' do
  action    :install
  version  '3.180.1'
  source   'STEP 3 URL'
end

See docs at https://docs.chef.io/resource_chocolatey_package.html.


Chocolatey::Ensure-Package
(
    Name: oh-my-posh,
    Version: 3.180.1,
    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  = '3.180.1'
   Source   = 'STEP 3 URL'
}

Requires cChoco DSC Resource. See docs at https://github.com/chocolatey/cChoco.


package { 'oh-my-posh':
  provider => 'chocolatey',
  ensure   => '3.180.1',
  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="3.180.1" 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 Sep 2021.

Description

Introduction

Oh my Posh is a custom prompt engine for any shell that has the ability to adjust the prompt string with a function or variable.

Oh my Posh 3 vs Oh my Posh 2

Oh my Posh 3 is the offspring of Oh my Posh, a prompt theme engine for PowerShell. Oh my Posh started out by being inspired from tools like oh my zsh when nothing was available specifically for PowerShell.

Over the years, I switched operating system/main shell quite a lot, even on Windows via the WSL. This made it so that my prompt wasn't portable enough, I wanted the same visual/functional experience regardless of the shell I was working in. Hello world Oh my Posh 3!

Concept

Traditionally, prompt tools work with custom scripts per theme (just like Oh my Posh did) or a lot of CLI configuration switches to define what it looks like. With Oh my Posh, I wanted to start from a single configuration file that could easily be shared anywhere, removing the need to really grasp what goes on underneath.

When you look at prompts like Agnoster or Paradox, you notice they usually consist of a few building blocks which contain one or more segments that display some sort of information. The configuration of Oh my Posh works exactly like that. Blocks are a combination of one or more segments.

The basic layout of the config file is as follows.

{
    "blocks": []
}

A block has properties that indicate its position and the segments it will render.

{
    "blocks": [
        {
            // positioning metadata (not shown)
            "segments": []
        }
    ]
}

A segment renders a single context like showing the current folder, user information or git status when relevant. It can be styled any way you want, resulting in visualizing the prompt you are looking for.

For your convenience, the existing themes from Oh my Posh have been added to version 3, so you can get started even without having to understand the theming. So, let's no longer waste time on theory, have a look at the configuration guide to get started right away!


tools\chocolateyinstall.ps1
$ErrorActionPreference = 'Stop';
$pp = Get-PackageParameters


$InstallArgs = @{ 
    PackageName    = $env:ChocolateyPackageName
    FileType       = 'exe'
    SilentArgs     = '/VERYSILENT'
    Url64bit       = 'https://github.com/JanDeDobbeleer/oh-my-posh/releases/download/v3.180.1/install.exe'
    Checksum64     = 'df603264158e7367e08bcc78633f58d7e2f0f54978bd17018c1f50905994f235bd28e637352ff3d2864ff0d616d898a202bb7ff24b87240808892aef1b37a5cf'
    ChecksumType64 = 'sha512'
}

Install-ChocolateyPackage  @InstallArgs

Write-Output "PROFILE: $profile"
if (Test-Path $profile) {
    $oldprofile = Get-Content $profile
    $OhMyPoshInprofile = @(
        ($oldprofile | Select-String -SimpleMatch 'Import-Module oh-my-posh' | Select-Object -ExpandProperty Line)
        ($oldprofile | Select-String -SimpleMatch 'Invoke-Expression (oh-my-posh --init --shell pwsh' | Select-Object -ExpandProperty Line)
        ($oldprofile | Select-String -SimpleMatch 'Set-PoshPrompt' | Select-Object -ExpandProperty Line)
    )

    if ($pp['Theme']) {
        $themeName = $pp['Theme']
        if (Test-Path "$env:LocalAppDataPrograms/oh-my-posh/themes/$($themeName).omp.json") {
            $ohMyPoshprofileLine = "Invoke-Expression (oh-my-posh --init --shell pwsh --config ""$env:LocalAppData/Programs/oh-my-posh/themes/$($themeName).omp.json"")"
            # $ohMyPoshprofileLine = "Set-PoshPrompt -Theme $themeName" # Suggestion for possible alternative
            if ($OhMyPoshInprofile) {
                # If a theme is set, Overwrite old line to set new theme
                foreach ($existingLine in $OhMyPoshInprofile) {
                    Write-Host "Overwriting Old Oh-My-Posh line: $existingLine with $ohMyPoshprofileLine"
                    $oldprofile | ForEach-Object { $_ -replace $existingLine, $ohMyPoshprofileLine } | Set-Content -Path $profile -Force
                }
            }
            else {
                Add-Content -Path $profile -Value $ohMyPoshprofileLine -Force
            }
        }
        else {
            Throw "Could not find Theme $themeName @ $env:LocalAppDataPrograms/oh-my-posh/themes/$($themeName).omp.json";
        }
        if (-Not($OhMyPoshInprofile)) {
            Add-Content -Path $profile -Value "Invoke-Expression (oh-my-posh --init --shell pwsh --config ""$env:LocalAppData/Programs/oh-my-posh/themes/$($themeName).omp.json"")";
            Add-Content -Path $profile -Value 'Use the command ''Get-PoshThemes'' to display every available theme in the current directory'
            Add-Content -Path $profile -Value '# For information about setting your oh-my-posh themes: https://ohmyposh.dev/docs/installation#3-replace-your-existing-prompt'
        }
  
  
        if (-Not($OhMyPoshInProfile)) {
            # Add-Content -Path $PROFILE -Value 'Invoke-Expression (oh-my-posh --init --shell pwsh --config "$(scoop prefix oh-my-posh)/themes/jandedobbeleer.omp.json")';
            Add-Content -Path $PROFILE -Value 'Set-PoshPrompt -Theme jandedobbeleer'; # Newer method of setting theme
            Add-Content -Path $PROFILE -Value 'Use the command ''Get-PoshThemes'' to display every available theme in the current directory'
            Add-Content -Path $PROFILE -Value '# For information about setting your oh-my-posh themes: https://ohmyposh.dev/docs/installation#3-replace-your-existing-prompt'
        }
    }

    Write-Host "oh-my-posh has been added to your profile. You may wish to append 'Set-PoshPrompt paradox' to set a theme"
}
else {
    Write-Host "No Powershell profile was found. You may wish to create a profile and append 'Invoke-Expression (oh-my-posh --init --shell pwsh --config ""$env:LocalAppData/Programs/oh-my-posh/themes/themename.omp.json"")' to enable oh-my-posh. 'Get-PoshThemes' will list available themes for you"
}
tools\chocolateyuninstall.ps1
#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' -or $line -like 'Invoke-Expression (oh-my-posh --init --shell pwsh*') {
            continue
        }
        if($line -like 'Set-PoshPrompt*') {
            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."
  }

Log in or click on link to see number of positives.

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 3.180.2 255 Tuesday, September 14, 2021 Approved
Oh-My-Posh 3.180.1 2447 Friday, September 10, 2021 Approved
Oh-My-Posh 3.180.0 2129 Sunday, September 5, 2021 Approved
Oh-My-Posh 3.177.0 1352 Saturday, September 4, 2021 Approved
Oh-My-Posh 3.176.0 91 Saturday, September 4, 2021 Approved
Oh-My-Posh 3.175.0 55 Saturday, September 4, 2021 Approved
Oh-My-Posh 3.174.0 14 Saturday, September 4, 2021 Approved
Oh-My-Posh 3.144.0 2129 Sunday, April 25, 2021 Approved

This package has no dependencies.

Discussion for the Oh-My-Posh Package

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.
comments powered by Disqus