Closed czhang03 closed 6 years ago
I like @Jaykul handling of prompt, lines and blocks better and I like the module name PowerLine
better. But I do like @JanJoris color theming support, Posh-Git support and admin/failed command indicators.
Thx. oh-my-posh started out as more than just theming. I should rename it to posh-theme or something as it supports a lot more than just powerline styled prompts. You can do whatever with it. I do like this implementation, there's some cool stuff in here.
Having used oh-my-zsh, I loved the idea of oh-my-posh, but in both cases, their idea of a "theme" is really just a full-blown custom prompt function ... my goal is something much more modular, so it's easier to share and tweak other people's prompts.
I'm desperate to get rid of this mess I created and avoid creating a new mess.
You can already style the PowerLine prompt to not use background colors, and ditch PowerLine separators, so you should be able to build any prompt you like. That is simply not well documented yet.
I'm working on the nested blocks support and a few other pieces like #5 which seem important to finish before writing docs for themeing :stuck_out_tongue_winking_eye:
I would definitely like to collect themes, once I've stopped changing the design.
There are a few more built-in functions necessary. I have included a Get-Elapsed
but turning this into a module broke using $?
for success, so I need to publish the hack I'm using as Test-Success
to show how to change background colors if there's an error (or just output an "x"), and probably need to add a couple others like Test-Elevation
...
I'd be happy to take suggestions and/or pull requests ;-)
+1 for Test-Elevated
or something like that. Currently, I use:
$global:Prompt_IsAdmin = (New-Object Security.Principal.WindowsPrincipal ([Security.Principal.WindowsIdentity]::GetCurrent())).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
Also, while I like the idea of smaller, more granular modules, the colors I would use for PowerLine would heavily influenced by the color theme I'm currently running. So if you don't do theming in this module, then perhaps there is some hook/registration between the theming module and this one so when I change color themes, my PowerLine block colors get updated as well.
Yeah ... I don't think I know an API for switching the color theme of the console. I mean, I have scripts to change the colors of console window shortcuts
, but I don't know how to change it in a running window...
ConEmu, of course, has functionality for themes -- and I'm thinking about sharing my config for that and some of the color-switching scripts that I have (it's not much, but I switch between normal, elevated, and presentation themes).
By the way, you can use the slightly shorter string overload:
([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole("Administrators")
And I've been testing using the well-known Administrators SID, it seems to work. Both of these return nothing if you're not elevated:
[Security.Principal.WindowsIdentity]::GetCurrent().Groups -eq "S-1-5-32-544"
[Security.Principal.WindowsIdentity]::GetCurrent().Owner -eq 'S-1-5-32-544'
I have seen another repo that is much similar to this repo.
Maybe you guys can discuss how to merge them together, so that we don't rebuild the wheels.
Here is the link to the repo: https://github.com/JanJoris/oh-my-posh