JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.01k stars 2.37k forks source link

I'm having two issues after the update from v2 to v3 #627

Closed eddynaka closed 3 years ago

eddynaka commented 3 years ago

Prerequisites

Description

After updating, I started to see this:

WARNING: You appear to have an unsupported Git distribution; setting $GitPromptSettings.AnsiConsole = $false. posh-git
recommends Git for Windows.

Also, I'm seeing duplicated information: image

I saw that you don't have the Paradox theme anymore. It had a nice feature (the time to the right), but I don't know how to add it again.

Environment

lnu commented 3 years ago

Did you follow the upgrade process? https://ohmyposh.dev/docs/upgrading/ The list of built-in themes is available here: https://ohmyposh.dev/docs/themes

eddynaka commented 3 years ago

Hello,

yes. Now, I'm using powerline, but I still don't know how to fix the duplicate information (ss above) and how to add the time aligned to the right.

JanDeDobbeleer commented 3 years ago

@eddynaka that message is coming from posh-git, same as the git status prefix you're seeing. You need to update your git using git for windows and can disable that prefix via their settings (I think using $PoshGitPromptSettings. EnablePromptStatus=$false). Paradox is available using Set-PoshPrompt paradox.

eddynaka commented 3 years ago

hi @JanDeDobbeleer , interesting! Because I'm using git for windows, the only different thing is that that is vfs style.

I tried to add this to my $PROFILE:

$GitPromptSettings.AnsiConsole = $false
$GitPromptSettings.EnablePromptStatus = $false

but yet it didn't work.

How do i configure the time to the right? is it possible?

JanDeDobbeleer commented 3 years ago

@eddynaka quick question, do you import oh-my-posh first or posh-git?

eddynaka commented 3 years ago

Hi @JanDeDobbeleer , this is my current config:

Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme  ~/.oh-my-posh.omp.json
$GitPromptSettings.AnsiConsole = $false
$GitPromptSettings.EnablePromptStatus = $false

Do I need to use both?

lnu commented 3 years ago

@eddynaka here's a sample of paradox with the time on the right:

{
  "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
  "blocks": [
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "root",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#ffe9aa"
        },
        {
          "type": "session",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#ffffff"
        },
        {
          "type": "path",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#91ddff",
          "properties": {
            "folder_icon": "\uF115",
            "folder_separator_icon": " \uE0B1 ",
            "style": "full"
          }
        },
        {
          "type": "git",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#193549",
          "background": "#95ffa4"
        },
        {
          "type": "python",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#100e23",
          "background": "#906cff",
          "properties": {
            "prefix": " \uE235 "
          }
        },
        {
          "type": "exit",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#ff8080",
          "properties": {
            "prefix": " \uE20F"
          }
        }
      ]
    },
    {
      "type": "prompt",
      "alignment": "right",
      "segments": [
        {
          "type": "time",
          "style": "plain",
          "foreground": "#007ACC",
          "properties": {
            "time_format": "15:04:05"
          }
        }
      ]
    },
    {
      "type": "newline"
    },
    {
      "type": "prompt",
      "alignment": "left",
      "segments": [
        {
          "type": "text",
          "style": "plain",
          "foreground": "#007ACC",
          "properties": {
            "prefix": "",
            "text": "\u276F"
          }
        }
      ]
    }
  ],
  "final_space": false
}
JanDeDobbeleer commented 3 years ago

@eddynaka you can use oh-my-posh without posh-git. Also, which theme is that? Because paradox is shipped with the module.

eddynaka commented 3 years ago

@lnu , thanks!

@JanDeDobbeleer , i think it's not shipping anymore. At least, the get-theme does not show it!

eddynaka commented 3 years ago

@JanDeDobbeleer , without posh-git, it does not show the part: "1 to push 1 uncommited".

JanDeDobbeleer commented 3 years ago

@eddynaka Get-Theme isn't a cmdlet anymore, you can use Get-PoshThemes.

eddynaka commented 3 years ago

got it! that fixed the time to the right and the warning string.

But I lost the part of the string where it showed the git part.

lnu commented 3 years ago

@eddynaka So what does it look like now?

eddynaka commented 3 years ago

Hi @lnu , below a SS: image

It's in main, but i have un-committed things, so before the upgrade it was showing the numbers like [x y z].

JanDeDobbeleer commented 3 years ago

@eddynaka what does git status say? Because in the first screenshot, both posh-git and oh-my-posh report the same.

eddynaka commented 3 years ago

image

In theory, i have a change in the submodule, so the submodule always showed me as a change that i had to make or fix.

doing the same to a specific place, i can see something different: image

am i missing icons? os the number 0 is correct there?

thank u again

lnu commented 3 years ago

for the missing icons you need to use one of the Nerd Fonts:https://ohmyposh.dev/docs/fonts

JanDeDobbeleer commented 3 years ago

@eddynaka support for submodules is likely something I have to add. I'll check back in the morning.

eddynaka commented 3 years ago

Hi @JanDeDobbeleer , got it.

strangely that i'm sure that that was working. but i dont know if that was because of the other import :)

let me try to update the fonts

lnu commented 3 years ago

@JanDeDobbeleer @eddynaka in the meantime, you can use the posh git segment instead of the git segment as a workaround for the submodule status.

eddynaka commented 3 years ago

how do i do that?

lnu commented 3 years ago

try to enable disable with this config(let both to see the difference and enable the one you want to keep):

        {
          "type": "poshgit",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#193549",
          "background": "#95ffa4"
        },
        {
          "type": "git",
          "style": "powerline",
          "powerline_symbol": "\uE0B0",
          "foreground": "#193549",
          "background": "#95ffa4"
        },

for the posh git segment, you need to have this in your ps profile:

import-module posh-git
$GitPromptSettings.EnableFileStatus = $true
$GitPromptSettings.EnablePromptStatus = $true

Not sure for the EnableFileStatus but you definitely need the EnablePromptStatus.

With both enabled you'll get something like this: image

eddynaka commented 3 years ago

Fixed the icons.

i will try later the configs above. thank you!

JanDeDobbeleer commented 3 years ago

@eddynaka can you give the output of git --no-optional-locks -c core.quotepath=false -c color.status=false status -unormal --short --branch when in that state?

maidamai0 commented 3 years ago

I have duplicated git status information too if I Import-Module posh-git. I keep Import-Module posh-git because it provides the auto-complete feature for git.

lnu commented 3 years ago

@maidamai0 And that's the reason I still import it too. But the git information should not be duplicated. What's your configuration(terminal, shell, ps profile, ...)?

JanDeDobbeleer commented 3 years ago

@maidamai0 did you import posh-git before oh-my-posh? Might want to try the other way around according to what I'm reading.

maidamai0 commented 3 years ago

@lnu

terminal

Windows terminal

shell

poweshell 7.1.3

ps profile

Import-Module posh-git
Import-Module oh-my-posh
Import-Module -Name Terminal-Icons
Set-PoshPrompt -Theme ~/.oh-my-posh.omp.json # based on star.omp.json
New-Alias ll ls

function Enter-AdminPSSession {
  Start-Process -Verb RunAs (Get-Process -Id $PID).Path
}

# Optionally also define a short alias name:
# Note: 'psadmin' is a nonstandard alias name; a more conformant name would be
#       the somewhat clunky 'etasn' 
#       ('et' for 'Enter', 'a' for admin, and 'sn'` for session)
Set-Alias psadmin Enter-AdminPSSession
Import-Module 'C:\Users\michael\Documents\vcpkg\scripts\posh-vcpkg'

@JanDeDobbeleer Yes I import posh-git before oh-my-posh

JanDeDobbeleer commented 3 years ago

@maidamai0 swap those two please (add it after the Set-PoshPrompt statement)

maidamai0 commented 3 years ago

@JanDeDobbeleer Still have duplicated git status

lnu commented 3 years ago

The order of the import has no impact, I swapped both to test and I still have only one status. Could you put a screenshot of the prompt? and the content of your custom theme?

JanDeDobbeleer commented 3 years ago

@lnu according to the docs it does actually. When posh-git detects a custom prompt it doesn't set it. But I asked the creator as the behavior seems to differ per person and I don't see what's causing it.

maidamai0 commented 3 years ago

@lnu I set to the build-in star theme and it has duplicated info too: image

maidamai0 commented 3 years ago

Get-PoshThemes shows correctly, if this helps. demo

lnu commented 3 years ago

And if you remove the posh git import the duplicated status is gone? Could you also print the result of get-module?

maidamai0 commented 3 years ago

Yes, the duplicated status gone if I remove the the posh-git form profile get-module gives: image

lnu commented 3 years ago

I'm using posh-git 1.0.0. If I rollback to your version I get the same issue: image Please update to the latest version of posh-git and it should work.

maidamai0 commented 3 years ago

upgrade posh-git fixed this issue, Thank you!

lnu commented 3 years ago

@JanDeDobbeleer the issue is related to this commit 320ec1d7d32467dfa924f929cd1849fc3c1e4b77 If posh git functions are called before the rendering, it adds itself at the start. Since the issue is only related to an old version of posh git, we can safely tell people to always use posh-git > 1.0.0 I remember we already had this issue a loooonnnnggg time ago.

JanDeDobbeleer commented 3 years ago

Let's get this back on track. @eddynaka can you give the output of git --no-optional-locks -c core.quotepath=false -c color.status=false status -unormal --short --branch when in that state?

eddynaka commented 3 years ago

Hello,

below the result: image

JanDeDobbeleer commented 3 years ago

@eddynaka can you copy that output as text for me? I already see a lowercase m rather than a uppercase one. Can you also modify a file in the repo (not the submodule) for me so I can see the difference?

eddynaka commented 3 years ago

Of course!

❯ git --no-optional-locks -c core.quotepath=false -c color.status=false status -unormal --short --branch
## main...origin/main
 m src/sarif-pattern-matcher

with some file modification:

❯ git --no-optional-locks -c core.quotepath=false -c color.status=false status -unormal --short --branch
## main...origin/main
 M src/Plugins/Tests.Security.Internal/Validators/SEC101_001.HttpAuthorizationRequestHeaderValidatorTests.cs
 m src/sarif-pattern-matcher
JanDeDobbeleer commented 3 years ago

@eddynaka fix incoming, missed that little bit of information. From the docs:

Submodules have more state and instead report M the submodule has a different HEAD than recorded in the index m the submodule has modified content ? the submodule has untracked files since modified content or untracked files in a submodule cannot be added via git add in the superproject to prepare a commit. m and ? are applied recursively. For example if a nested submodule in a submodule contains an untracked file, this is reported as ? as well.

eddynaka commented 3 years ago

@JanDeDobbeleer , with that, i wouldn't need the other extension, right? Only with oh-my-posh it would be enough to track everything

JanDeDobbeleer commented 3 years ago

@eddynaka correct

github-actions[bot] commented 5 months ago

This issue has been automatically locked since there has not been any recent activity (i.e. last half year) after it was closed. It helps our maintainers focus on the active issues. If you have found a problem that seems similar, please open a discussion first, complete the body with all the details necessary to reproduce, and mention this issue as reference.