Giter Site home page Giter Site logo

Comments (9)

JanDeDobbeleer avatar JanDeDobbeleer commented on May 11, 2024 1

You could achieve that with a custom command segment. That one accepts a shell command (and the shell to run it in, here being powershell) . If the command outputs a value, it will show that value.

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on May 11, 2024

I could add a switch to the properties which would allow this. For example:

"hide_error": true

Not sure if I want to make a general switch, I do get where you're coming from but it can get confusing.

What's also an option is to remove the segment from the theme altogether. A quick copy-paste, adjust and setting that as the theme will also hide it forever. Although that might take away its portability.

from oh-my-posh.

AjayKMehta avatar AjayKMehta commented on May 11, 2024

hide_error works.

I get your point about the general switch as it may open a can of worms. I like the idea of being able to dynamically determine visibility of a segment based on condition but embedding PowerShell code in JSON is quite ugly and no point in creating your own DSL for this 😀

from oh-my-posh.

AjayKMehta avatar AjayKMehta commented on May 11, 2024

@JanDeDobbeleer, one use case for a general switch or config setting for segment visibility is the following:

Say I want to add an 💾 indicator in my prompt to show that (Get-PSReadLineOption).HistorySaveStyle is set to SaveIncrementally or SaveAtExit and remove it if it's not set?

from oh-my-posh.

AjayKMehta avatar AjayKMehta commented on May 11, 2024

I created a theme (cool.json) with a command segment as suggested:

https://gist.github.com/AjayKMehta/1b5324a485a9db6e7d326276ab5786cf

The command is specified as "if ((Get-PSReadLineOption).HistorySaveStyle -ne 'SaveNothing'){'💾'} else {''}"

It seems to run the command the first time and not work subsequently. Even if I disable saving via Set-PSReadLineOption -HistorySaveStyle SaveNothing, I still see 💾 in the prompt.

Any help would be appreciated. Thanks.

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on May 11, 2024

It should not save state but run the command every time. I'll check!

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on May 11, 2024

I can reproduce this. As this is ran on a new instance of pwsh, it will only work IF this is set globally via for example your $PROFILE. Let me see if I can make it so it runs directly in your shell (which could break if you don't know what you're doing).

from oh-my-posh.

AjayKMehta avatar AjayKMehta commented on May 11, 2024

Thanks. That's what I figured as I tried changing the command to Get-Date and it worked fine.

from oh-my-posh.

JanDeDobbeleer avatar JanDeDobbeleer commented on May 11, 2024

Be aware the new version is now known as Oh my Posh V3 :-)

Install-Module oh-my-posh -Scope CurrentUser -AllowPrerelease

from oh-my-posh.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.