Comments (9)
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.
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.
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.
@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.
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.
It should not save state but run the command every time. I'll check!
from oh-my-posh.
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.
Thanks. That's what I figured as I tried changing the command to Get-Date
and it worked fine.
from oh-my-posh.
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)
- & was unexpected at this time. HOT 1
- feat: amrobytes - a new theme HOT 2
- left prompt character going to next line when python virtualenv is activated in pwsh + windows terminal. HOT 1
- WSL bash no git info on windows mounts HOT 1
- A changelog file with breaking changes would be nice HOT 1
- Prompt is often rendered in black and white HOT 3
- Oh My Posh not starting for cmd HOT 1
- 20+ second boot time HOT 2
- Allow transient prompt alignment (segments or left/right_template or whatever...) HOT 1
- Invoke-Expression is used HOT 1
- Android AArch64 build HOT 1
- iTerm2 shell integration HOT 1
- Ability to not process the command in `command`
- I always lost my customize when I open the new tab HOT 1
- The git segment doesn't render correctly when switching to a shorter branch name HOT 6
- plugin system like "oh-my-zsh" HOT 1
- python segment not working
- Firebase segment does not work on child folders HOT 2
- Line wrapping the time to 2nd line HOT 4
- Loss of appearance when resizing window HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from oh-my-posh.