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

Location stack in path block #634

Closed Aankhen closed 3 years ago

Aankhen commented 3 years ago

Prerequisites

Description

It would be very useful to have the path block show the size of the location stack if it’s available in the shell and contains more than one entry. In case it helps, the commands I know of to get the size are:

Environment

Steps to Reproduce

  1. pushd C:\dir1
  2. pushd C:\dir2
  3. pushd C:\dir3

Expected behavior: The path block shows something like:

Equivalent to 📂2 📁C:\dir3

Actual behavior: The path block shows only the folder (different one, sorry):

~ shown

lnu commented 3 years ago

something like this? image

But the behaviour is different between powershell and unix shells:

Aankhen commented 3 years ago

Yes, like that! (Just with the count hidden if there’s nothing pushed.) May I ask how you have that? I went through segment_path.go twice before creating this issue, but I must have missed something, unless it’s a customization of your own.

Thank you for listing the behaviour of the different shells—I only have experience with Bash myself, and all I could find in my brief searches was what I read about zsh. I guess fish would be one of the shells that couldn’t show the stack. As far as zsh goes, I’d defer to actual users on whether it would be useful to show it. They could always hide it if not.

lnu commented 3 years ago

I’ll push the branch later today

Aankhen commented 3 years ago

Thanks, guys! I wish every feature request went so smoothly! 😬

Do I need to do anything other than update to 3.137 and set stack_count_enabled?

lnu commented 3 years ago

Should be enough. And reopen or reload your shell.

Aankhen commented 3 years ago

I must be doing something wrong. This is my configuration for the block:

        {
          "type": "path",
          "style": "diamond",
          "powerline_symbol": "\uE0B0",
          "foreground": "#ffffff",
          "background": "#004e9d",
          "leading_diamond": "\uE0B6",
          "trailing_diamond": "\uE0B0",
          "properties": {
            "prefix": " \uE5FF ",
            "style": "mixed",
            "stack_count_enabled": true
          }
        }

And this is what I see: No stack count even after two `pushd`s

lnu commented 3 years ago

It's enough on my side. Don't forget to reload your shell. Tested on windows and macos:

image
Aankhen commented 3 years ago

Yes, it’s a new shell, but it doesn’t seem to be working:

No stack count indicator after `pushd`s

lnu commented 3 years ago

the config I use:

{
          "background": "#ff479c",
          "foreground": "#ffffff",
          "powerline_symbol": "",
          "properties": {
            "folder_separator_icon": "  ",
            "home_icon": "~",
            "prefix": "   ",
            "style": "folder",
            "stack_count_enabled": true
          },
          "style": "powerline",
          "type": "path"
        },

I also tried your config:

image
Aankhen commented 3 years ago

Odd… are you using your fork or are you using the just-released version?

lnu commented 3 years ago

I found an issue with set-poshprompt, let me fix this.

It works when invoke directly in the profile like this Invoke-Expression (&"/usr/local/bin/oh-my-posh" --init --shell=pwsh --config=/Volumes/data/tools/ohmyposh/jandedobbeleer_custom3.omp.json) but not with set-poshprompt(which does the same) I'm checking why.

So it's basically the same issue as described here:https://github.com/JanDeDobbeleer/oh-my-posh2/blob/c4919171881e8384a0af4aa5dec26d3ad0ea5f88/README.md#adding-stack-count-to-a-custom-theme https://github.com/JanDeDobbeleer/oh-my-posh2/issues/113

A workaround for the time being is to not use Set-PoshPrompt but this in your Powershell profile: Invoke-Expression (oh-my-posh --init --shell pwsh --config "$(scoop prefix oh-my-posh)/themes/jandedobbeleer.omp.json")

Explained in the documentation here:https://ohmyposh.dev/docs/installation#3-replace-your-existing-prompt

I'll try to see what can be done to make it work with Set-PoshPrompt

lnu commented 3 years ago

More context:https://github.com/PowerShell/PowerShell/issues/12868

lnu commented 3 years ago

@Aankhen Can you try the latest version and tell us if it's ok?

Aankhen commented 3 years ago

The latest version works! Thanks for chasing this down. That was a pretty confusing bug and I really appreciate all the work you put into fixing it. 😊

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.