jandedobbeleer / oh-my-posh Goto Github PK
View Code? Open in Web Editor NEWThe most customisable and low-latency cross platform/shell prompt renderer
Home Page: https://ohmyposh.dev
License: MIT License
The most customisable and low-latency cross platform/shell prompt renderer
Home Page: https://ohmyposh.dev
License: MIT License
CONTRIBUTING
guideI am a user of oh-my-posh 2 with a pretty custom profile that primarily relies on shell commands (kubectl
, az
, and so on). I've found through experimentation that it's far more responsive to run all these commands in parallel rather than a serial foreach loop - rather than the prompt sort of "popping in" on a delay, it's almost instant.
I'm in the process of trying to update to v3 and noticed the segments get executed as a byproduct of calling enabled()
which happens in a foreach-over-foreach (foreach block/foreach segment in the block).
While I've not yet finished converting or testing, I'm guessing you'd still see a pretty decent perf improvement for prompts that use a lot of commands if things were done in parallel and rendered after all the info is gathered.
Admittedly I'm more of a junior level Go programmer so I may be missing something here and could be totally wrong. And, also, since I've not yet finished converting my theme I can't actually cite stats. It just seems logical that if the shell is executing the oh-my-posh executable, then that executable is starting a separate process in serial for additional shell commands that some multithreading could speed that up.
CONTRIBUTING
guideTried running in Windows Terminal and in Powershell directly, the symbols in many themes are not appearing correctly.
Expected behavior: No box symbols
CONTRIBUTING
guide[Description of the bug or feature]
installed oh-my-posh according to the steps mentioned in the readme
Expected behavior: The pathname on the terminal should be C:\Users\Jibin Thomas\dev
Actual behavior: The path is being truncated till the space C:\Users\Jibin
CONTRIBUTING
guideRegression when using a PSDrive. Theme is not rendered anymore.
Before 3.20.4:
After 3.23.5:
Navigate to the PowerShell temp drive
cd temp:
Expected behavior: [What you expected to happen]
Normal behavior as before
Actual behavior: [What actually happened]
Theme doesn't render anymore
CONTRIBUTING
guide[Description of the bug or feature]
cd \
Expected behavior: In the prompt displays an error "-error 0"
Actual behavior: there are no errors in the prompt
Since this is a (almost) platform-agnostic shell themer, is there a way to support Command Prompt in Windows?
For inspiration, you can check out how Cmder does it.
For the most part, it just requires changing the prompt
environment variable. Like this, for example:
SETX /M PROMPT "$E[1;32;40m→ $E[1;36;40m$p$E[1;35;40m› $E[1;37;40m"
_
CONTRIBUTING
guideHi Jan,
just a simple (and maybe stupid) question. 😊
Where do you find all the codes for the symbols like the GitHub Icon \uF408
?
Many thanks in advance!
Cheers,
Maurice
CONTRIBUTING
guideUsing the example theme from the documentation and running oh-my-posh manually, I don't see background colors rendered.
I'm not sure if this is an artifact of trying to execute it manually or if this means there's something else I need to set. I was trying to do some testing to verify #177 and try converting my custom v2 theme to v3, but I'm not willing to mess up my existing prompt environment if I can't tell if this is going to work the same.
First, create example.json
with the theme from the docs. Note it has a foreground and background color.
Theme:
{
"final_space": true,
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "path",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#ffffff",
"background": "#61AFEF",
"properties": {
"prefix": " ",
"style": "folder"
}
}
]
}
]
}
Next, run the oh-my-posh executable and pass it the example.json
as the configuration, like:
posh-darwin-amd64 -config ./example.json
Expected behavior: I expected to see the current folder shown with a white foreground and a light blue background.
Actual behavior:
Note there's no light blue background and the foreground color is not white.
CONTRIBUTING
guideSet-PoshPrompt
doesn't resolve path using home ~
~/OneDrive/Documents/PowerShell/.go-my-posh.json
From a good prompt, I'll run
Set-PoshPrompt ~/OneDrive/Documents/PowerShell/.go-my-posh.json
Set-PoshPrompt ( Resolve-Path ~/OneDrive/Documents/PowerShell/.go-my-posh.json )
Expected behavior: prompt should always be ➜ ~/OneDrive/Documents/PowerShell
Actual behavior:
➜ ~/OneDrive/Documents/PowerShell Set-PoshPrompt ~/OneDrive/Documents/PowerShell/.go-my-posh.json
[email protected] PowerShell 96 ﲵ pwsh Set-PoshPrompt ( Resolve-Path ~/OneDrive/Documents/PowerShell/.go-my-posh.json )
➜ ~/OneDrive/Documents/PowerShell
You can see that Set-PoshPrompt ~/OneDrive/Documents/PowerShell/.go-my-posh.json
causes the prompt to become the default powerline: carl@MACPC PowerShell 96 ﲵ pwsh
Workaround is to call Resolve-Path
first like:
Set-PoshPrompt ( Resolve-Path ~/OneDrive/Documents/PowerShell/.go-my-posh.json )
CONTRIBUTING
guideAfter installing v.3.23, the custom theme that I created that uses an envvar
segment for the prompt does not display correctly after the module is imported. Subsequently, the prompt is written correctly.
I am guessing this is because the prompt is written before the initial call to Set-PoshContext
now?
See screenshot below:
Set-PSReadLineOption -HistorySaveStyle SaveIncrementally
Import-Module 'posh-git', 'oh-my-posh' -Force
function Set-EnvVar {
$env:POSH=$(if ((Get-PSReadLineOption).HistorySaveStyle -ne 'SaveNothing'){[char]::ConvertFromUtf32(0x1f4be)} else {''})
}
if (Get-Alias 'Set-PoshContext' -ErrorAction Ignore) {
Remove-Alias 'Set-PoshContext'
}
New-Alias -Name 'Set-PoshContext' -Value 'Set-EnvVar' -Scope Global
Set-PoshPrompt -Theme "$PSScriptRoot\Themes\cool.json"
Expected behavior:
I expected to see a segment at the end with 💾 in the prompt after running the code (copied from my profile.ps1
).
Actual behavior:
There is no segment at the end with 💾 in it. Subsequently, the prompt is written correctly, i.e. a segment at the end with 💾 .
Goal: a segmnet that shows you're inside the WSL. There should be an evironment variable we can use: WSL_DISTRO_NAME
. If that one's set, you know you're inside of the WSL.
CONTRIBUTING
guide[Description of the bug or feature]
Text truncates and wraps in an odd way with nushell. I'm not sure what's going on.
The strange thing here is the cursor is as far right as possible and that point is between the o and r in the word selector.
If I hit enter with the cursor there it executes the entire line just fine.
If I hit backspace it starts deleting characters from the end of the line where it says first 5 but the cursor moves from where it's at between the o and r by one space left.
Windows
zsh
counts the line length but includes the escape sequences which results commands being continued on the second line (or wrong spot) too soon.
First of all, ❤️ this module! Finally switched over from oh-my-posh
🙂
I like your default theme (jandedobbeleer) but it shows "BATT ERR" on my desktop because no battery info, of course. IMHO it's better to not display the segment if no info but others may disagree.
To cater for both cases, it would be great if you could optionally specify a condition (scriptblock that returns boolean for example) for each segment in the JSON config that determines if the segment gets displayed or not.
CONTRIBUTING
guideWhen using the terminal, the text seems to wrap weirdly,
Seems to wrap around early, and doesn't continue on a newline, overwriting the PS1 text
Expected behavior: Text wraps around at the end of the window
Actual behavior: Text wraps around early / overwrites PS1 text
In comments for #26, I mentioned wanting to create a segment that displays an icon only if (Get-PSReadLineOption).HistorySaveStyle -ne 'SaveNothing'
. This does not work correctly because each time, the command gets run in a new instance of pwsh
.
Theme used to test this: https://gist.github.com/AjayKMehta/1b5324a485a9db6e7d326276ab5786cf
@JanDeDobbeleer said he would look into seeing if he can modify the code so that a command can be run directly in your shell fixing this problem.
CONTRIBUTING
guideposh-git's contextual autocomplete is not working if I have these three lines in my $profile:
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt powerlevel10k_lean
Interestingly, if I remove those and import them at the commandline in that same order, everything works just fine.
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt powerlevel10k_lean
cd C:\path\to\git\repo
git add
(include a space after "add") and hit {TAB}Expected behavior: Terminal autocompletes to: git add dir/to/filetoadd.txt
Actual behavior: Terminal autocompletes to something else, like git add .\.git\
CONTRIBUTING
guideAfter adding a newline the prompt position doesn't seem to be calculated correct. Notice the vertical bar on the right side of the screenshot.
prompt = "= `{{$(c:\\path\\to\\posh-windows-amd64.exe -config C:\\path\\to\\copy.json | str collect)}}`"
Expected behavior: [What you expected to happen]
I excpect the prompt location to be next to the >
Actual behavior: [What actually happened]
the prompt location is moved over to the right about the same spot as if there wasn't a newline in my copy.json.
copy.json
{
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "time",
"style": "plain",
"foreground": "#E5C07B",
"properties": {
"time_format": "2006-01-02 3:04:05.000 AM",
"prefix": "",
"postfix": ""
}
},
{
"type": "root",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#100e23",
"background": "#ffe9aa",
"properties": {
"root_icon": "襁"
}
}
]
},
{
"type": "newline"
},
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "path",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#ffffff",
"background": "#3364a1",
"properties": {
"home_icon": "~",
"folder_icon": "",
"windows_registry_icon": "",
"folder_separator_icon": " ",
"style": "short"
}
},
{
"type": "git",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#000000",
"background": "#95ffa4",
"properties": {
"branch_icon": "",
"branch_identical_icon": "≣",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_gone_icon": "≢",
"branch_untracked_icon": "\u2262",
"local_working_icon": "",
"local_staged_icon": "",
"rebase_icon": " ",
"cherry_pick_icon": " ",
"detached_icon": " ",
"tag_icon": "笠",
"display_stash_count": true,
"stash_count_icon": "\uF692 ",
"merge_icon": "\uE726 ",
"display_upstream_icon": true,
"github_icon": "\uE709",
"bitbucket_icon": "\uE703",
"gitlab_icon": "\uE296",
"git_icon": "\uE702"
}
},
{
"type": "python",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#100e23",
"background": "#906cff",
"properties": {
"prefix": " "
}
},
{
"type": "exit",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#ffffff",
"background": "#ff8080",
"properties": {
"prefix": ""
}
}
]
}
],
"final_space": true
}
oh-my-posh
supports showing origin symbols for git repositories (github/gitlab/bitbucket), so go-my-posh
should have this as well.
Is there planned, or could there be, the following feature:
Some way to implement in a function block? I see other block types such as spotify, git, battery, shell, exit and others.
A "function" block that is digested and renders would be extremely versatile.
[*] I have read and understand the CONTRIBUTING
guide
[*] I looked for duplicate issues before submitting this one
I followed the docs and upgraded oh my posh 2 to V3 on my Win10 machine using Powershell in admin mode. When I run the terminal I get the following exception:
PC=0x50c79a0000
syscall.loadsystemlibrary(0xc000010e00, 0xc000012800, 0xc000012800, 0x20)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/runtime/syscall_windows.go:136 +0xe7
syscall.LoadDLL(0xfe1e92, 0xb, 0xc000024000, 0xc00001a000, 0xc0000758d8)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/dll_windows.go:81 +0x16a
syscall.(*LazyDLL).Load(0xc0000041e0, 0x0, 0x0)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/dll_windows.go:245 +0xc8
syscall.(*LazyProc).Find(0xc000043bf0, 0x0, 0x0)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/dll_windows.go:300 +0xbf
syscall.(*LazyProc).mustFind(...)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/dll_windows.go:318
syscall.(*LazyProc).Addr(...)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/dll_windows.go:327
syscall.GetUserProfileDirectory(0x1f4, 0xc0001241a0, 0xc0000759b8, 0xc0001241a0, 0x509fe3f4a0
)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/zsyscall_windows.go:1910 +0x3e
syscall.Token.GetUserProfileDirectory(0x1f4, 0xc00000ef90, 0x2c, 0x0, 0x0)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/syscall/security_windows.go:368 +0x8f
os/user.current(0x0, 0x0, 0x0)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/os/user/lookup_windows.go:217 +0x1c7
os/user.Current.func1()
C:/hostedtoolcache/windows/go/1.15.2/x64/src/os/user/lookup.go:15 +0x29
sync.(*Once).doSlow(0x10f7de0, 0xfef020)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/sync/once.go:66 +0xf7
sync.(*Once).Do(...)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/sync/once.go:57
os/user.Current(0xc0001029c0, 0xc000102990, 0xc000005a60)
C:/hostedtoolcache/windows/go/1.15.2/x64/src/os/user/lookup.go:15 +0x105
main.(*environment).getCurrentUser(0xc000006050, 0xc000005a00, 0xc0000059e0, 0xc0000059c0)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/environment.go
:99 +0x29
main.(*session).getUserName(0xc0000059a0, 0x0, 0x0)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/segment_sessio
n.go:64 +0x68
main.(*session).getFormattedText(0xc0000059a0, 0x0, 0x0)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/segment_sessio
n.go:40 +0x47
main.(*session).string(0xc0000059a0, 0x1017801, 0xc000006050)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/segment_sessio
n.go:31 +0x32
main.(*Segment).string(...)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/segment.go:72
main.(*engine).renderBlockSegments(0xc000075f40, 0xc0000401e0, 0x0, 0x0)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/engine.go:97 +
0x1c3
main.(*engine).render(0xc000075f40)
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/engine.go:126
+0xe5
main.main()
D:/a/oh-my-posh3/oh-my-posh3/src/github.com/JanDeDobbeleer/oh-my-posh3/main.go:64 +0x
3f5
rax 0x7ffe253672d4
rbx 0xffffffffffbadd11
rcx 0x41
rdi 0x509fd91700
rsi 0x7ffe253672d4
rbp 0x0
rsp 0x509fcbef00
r8 0x0
r9 0x8ac
r10 0x0
r11 0x509fe3f430
r12 0x7ffe29330000
r13 0x7ffe253610e8
r14 0xc000007a
r15 0x7ffe25365c70
rip 0x50c79a0000
rflags 0x10206
cs 0x33
fs 0x53
gs 0x2b```
My PS profile:
$PSDefaultParameterValues["Out-File:Encoding"] = "utf8"
$MaximumHistoryCount = 1000;
Import-Module posh-git
Import-Module oh-my-posh
Set-PoshPrompt -Theme agnoster
Set-Location C:\repos
Expected behavior: [What you expected to happen]
Terminal starts without issues
Actual behavior: [What actually happened]
Oh my pish throws an exception
CONTRIBUTING
guideTerminal title is not set to current directory. Perhaps it could be made into optional setting where different values can be added into it?
Import-Module oh-my-posh
Expected behavior: Title has current path
Actual behavior: Current shell name is present
Since the module will not load without Posh-Git, it should be in the required modules of the manifest so that install-module (and install-psresource) automatically install the dependency.
Alternatively, remove posh-git from the main psm1 dependency and only do a check if git related segments are used (preferred)
Hi,
I am still facing icons issue on Powershell with the theme "jandedobbeleer.json".
Meslo LGM NF fonts are installed.
Here the theme file coming directly from the module:
I suppose the encoding is broken.
I am using:
Thanks
I'm messing around with oh-my-posh in nushell and the shell segment is coming up as cmd
since it appears to run under cmd.exe. Providing the -shell
arg doesn't change the string in the shell segment.
I also tried to use the -shell
arg from PowerShell and Bash and it always returns the string in the environment variable.
On quick inspection, I don't see why the code isn't working.
Hi, I might be missing something fundimental, but it appears that the characters representing items on the prompt are incorrect-ish?
If I edit the theme in vscode, only certain glyphs render correctly:
I'm wondering if there's a character encoding thing going on with the file maybe?
Character encoding is broken in prompt function, but not when I call oh-my-posh directly.
Prompt doesn't render icons, but if you run oh-my-posh directly with the same config it renders as expected.
Prompt function script:
[ScriptBlock]$Prompt = {
$realLASTEXITCODE = $global:LASTEXITCODE
if ([string]::IsNullOrEmpty($realLASTEXITCODE) ) { $realLASTEXITCODE = 0 }
& oh-my-posh -config C:\Users\chunt\.ohmyposh.json -error $realLASTEXITCODE -pwd $PWD.Path
$global:LASTEXITCODE = $realLASTEXITCODE
Remove-Variable realLASTEXITCODE -Confirm:$false
}
Set-Item -Path Function:\prompt -Value $Prompt -Force
}
CONTRIBUTING
guideOh-My-Posh-3 commands are not working when I upgrade the module.
Just followed the instructions given here - https://ohmyposh.dev/docs/upgrading
Expected behavior: The commands should work since no specific minimum version of PowerShell is specified anywhere in the docs.
CONTRIBUTING
guideIf I'm understanding the new structure, it seems like the only way(s) of creating a new type of segment are to either run a subprocess or write a new module for Oh-My-Posh. Is that correct? The reason I ask is that I have a Powershell function that returns the execution time of the last command, and that uses shell features (get-history
) to get the data. So it can't be run in either of the two ways that seem to now be available.
I understand that the resulting configuration would not be portable across shells, but that isn't an issue for me.
Is this an intended limitation of the new version, or is it likely to be possible to do this at some point?
CONTRIBUTING
guideSelected theme is not loaded by name or path (that contains spaces), but get-themes
is working.
Oh My Posh is installed in ~\OneDrive - XXX\Documents\PowerShell\Modules\oh-my-posh\
When using theme from there (either by referencing it by name or by full path), it's not working.
When using theme from a path without spaces it works.
Expected behavior:
Selected theme to be used
Actual behavior:
Default theme used
CONTRIBUTING
guideWhen navigating to the registry, the path segment does not show the registry path.
Oh-my-posh3:
Default behavior:
Expected behavior: Expected path segment to show: HKLM:\
Actual behavior: Previous path is displayed
CONTRIBUTING
guideI'd like to add some special handling if detected running in an ssh session.
Would an ssh specific segment be best for this? Or would some properties on the hostname in the session segment be more appropriate. I'm thinking like ssh-foreground, ssh-background, ssh-icon.
Vanilla posh-git shows staging (index) and working directory information in different color which is same as color scheme used by git status
command.
When using Paradox theme, it shows everything using single color:
I am guessing there is a way to override all prompt colors but if this is part of theme, that would be great.
If someone knows how to change color of these info, please let me know.
Thanks.
Copied from here
CONTRIBUTING
guideFirst of all I totally love this project and it makes using the CLI much more enjoyable for me.
Ok now to the actual idea:
I use oh-my-posh for the powershell which I mainly run inside the windows terminal.
Basically there are a couple of nice themes for the terminal, which map the 16 basic ANSI colors to nicer-looking ones.
So I thought about how I could re-use the color scheme from the windows terminal theme in my oh-my-posh theme without copying all the colors over and fine-tuning them there.
The old oh-my-posh used the 16 basic colors which were adapted by the windows terminal theme quite nicely.
In the end i would like to be able to specify the basic 16 ANSI colors in a theme .json
like in this example segment:
{
"type": "git",
"style": "powerline",
"powerline_symbol": "\uE0B0",
"foreground": "black",
"background": "lightYellow"
},
Maybe also using a prefix for color names such as "$black"
and "$lightYellow"
to make the names more recognizable and easier distinguish between hex and name.
I would like to contribute the code myself.
Hey,
its me again..
i'm playing around with different themes and their configuration and come along with the following behaviour..
when my notebook is plugged in and fully charged, i get the "BATT ERR", when its loading it shows the percentage in green and when its not plugged in the information is displayed in red.
is it only on my machine with the batt err ?
CONTRIBUTING
guideI'd like the git segment to include some icon to indicate there are local changes in working or staged, but without the detailed status string like ~1
or ?1
{
"type": "git",
"style": "plain",
"foreground": "#D0666F",
"properties": {
"branch_icon": "",
"branch_identical_icon": "",
"branch_ahead_icon": "",
"branch_behind_icon": "",
"branch_gone_icon": "",
"display_status": true,
"status_separator_icon": "",
"local_working_icon": "\u2717",
"local_staged_icon": "\u2717",
"commit_icon": "",
"rebase_icon": "",
"tag_icon": "",
"cherry_pick_icon": "",
"merge_icon": "",
"working_color": "#FFFF00",
"staging_color": "#00FF00",
"status_colors_enabled": true,
"color_background": false,
"prefix": " ",
"postfix": ""
}
}
For these example shell commands that create blah
, git add it, then create blah2
:
➜ ~/repo develop $ touch blah
➜ ~/repo develop ✗ ?1 $ git add blah
➜ ~/repo develop ✗ +1 $ touch blah2
➜ ~/repo develop ✗ +1 ✗ ?1 $ git status
On branch develop
Your branch is up to date with 'origin/develop'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: blah
Untracked files:
(use "git add <file>..." to include in what will be committed)
blah2
Expected behavior: Prompt is ➜ ~/repo develop ✗ $
(colored appropriately based on working_color and staging_color) If both working and staged changes, then two ✗
with one of each color .
Actual behavior: Prompt is ➜ ~/repo develop ✗ ?1 $
or ➜ ~/repo develop +1 $
I could imagine a settings like status_display_details
that controls whether https://github.com/JanDeDobbeleer/oh-my-posh3/blob/23233bc383b1eebe61b6493fd78140da3f2fdb83/segment_git.go#L133 includes the whole gitStatus string, or just the prefix.
CONTRIBUTING
guideThe git segment doesn't work anymore. Last version it worked for me was 3.23.5. In the screenshot you can see I checked 2 newer versions (2.24.3 and 2.26.1)
I checked both with a PSDrive path (my normal operation, GIT:/bgelens.github.io
) and normal filesystem path (/Users/bengelens/git/bgelens.github.io
).
Load explicit version via profile:
Working version:
#requires -Module @{ModuleName = 'oh-my-posh'; RequiredVersion = '3.23.5'}
Non working version:
#requires -Module @{ModuleName = 'oh-my-posh'; RequiredVersion = '3.26.1'}
Navigate to a git repository on disk
Expected behavior: [What you expected to happen]
Should render
Actual behavior: [What actually happened]
Does not render
CONTRIBUTING
guideI installed Oh-My-Posh via powershell modules and tried out the themes with Get-PoshThemes
and Set-PoshPrompt ...
.
Those commands are working fine.
Then I git cloned the repo, followed the Manual Installation Guide with creating C:\Tools
and downloading the script there.
I copied over the Themes in the Sub-Directory C:\Tools\PoshThemes
from the cloned repository.
But when I insert the code from below into $PROFILE
(= Microsoft.Powershell_profile.ps1) the prompt doesn't seem to load, instead I get a regular prompt from powershell.
[ScriptBlock]$Prompt = {
$realLASTEXITCODE = $global:LASTEXITCODE
& "C:\Tools\oh-my-posh.exe" -config "C:\Tools\PoshThemes\powerlevel10k_classic.json" -error $realLASTEXITCODE -pwd $PWD
$global:LASTEXITCODE = $realLASTEXITCODE
Remove-Variable realLASTEXITCODE -Confirm:$false
}
Set-Item -Path Function:prompt -Value $Prompt -Force
The Prompt works fine if I use the following inside $PROFILE
, but the loading time is around 0,5~0,7 seconds.
Set-PoshPrompt powerlevel10k_classic
mkdir C:\Tools
Invoke-Webrequest https://github.com/JanDeDobbeleer/oh-my-posh3/releases/latest/download/posh-windows-amd64.exe -OutFile C:\Tools\oh-my-posh.exe
C:\Tools\PoshThemes
notepad $PROFILE
and paste the sample code from above.Expected behavior: Prompt of Oh-My-Posh when starting a new shell.
If the failure would be in the Theme, I'd at least expect the default look as mentioned in the wiki.
Actual behavior: Regular Prompt of Powershell
CONTRIBUTING
guideIf you have a prompt that ends up wrapping to the next line and then ending, the next line will have a background color that matches the background of the segment at the end of the previous line.
Put another way:
{
"blocks": [
{
"alignment": "left",
"segments": [
{
"foreground": "#ff8080",
"invert_powerline": false,
"leading_diamond": "",
"powerline_symbol": "",
"properties": {
"always_enabled": false,
"display_exit_code": true,
"error_color": "#e91e63",
"postfix": "]",
"prefix": "[⌧ EXIT"
},
"style": "powerline",
"trailing_diamond": "",
"type": "exit"
},
{
"background": "#ffe9aa",
"foreground": "#100e23",
"invert_powerline": false,
"leading_diamond": "",
"powerline_symbol": "",
"properties": {
"root_icon": "☠"
},
"style": "powerline",
"trailing_diamond": "",
"type": "root"
},
{
"background": "#000000",
"foreground": "#ffffff",
"invert_powerline": false,
"leading_diamond": "",
"powerline_symbol": "",
"properties": {
"postfix": " ",
"user_info_separator": "@"
},
"style": "powerline",
"trailing_diamond": "",
"type": "session"
},
{
"background": "#0000c0",
"foreground": "#ffffff",
"invert_powerline": false,
"leading_diamond": "",
"powerline_symbol": "",
"properties": {
"prefix": " ",
"style": "short"
},
"style": "powerline",
"trailing_diamond": "",
"type": "path"
},
{
"background": "#00ffff",
"foreground": "#000000",
"invert_powerline": false,
"leading_diamond": "",
"powerline_symbol": "",
"properties": {
"command": "o=$(dotnet --version 2>/dev/null); X=$?; if [ $X -eq 0 ]; then { echo $o; exit 0; }; elif [ $X -eq 145 ]; then { echo \"[unsupported global.json]\"; exit 0; }; else exit 1; fi",
"prefix": " ",
"shell": "bash"
},
"style": "powerline",
"type": "command"
},
{
"background": "#ebcc34",
"foreground": "#000000",
"invert_powerline": false,
"leading_diamond": "",
"powerline_symbol": "",
"properties": {
"text": "This is a really long line that should cause things to wrap and might not end nicely."
},
"style": "powerline",
"type": "text"
},
{
"background": "#00cc00",
"foreground": "#000000",
"powerline_symbol": "",
"properties": {
"bitbucket_icon": "",
"branch_ahead_icon": "↑",
"branch_behind_icon": "↓",
"branch_icon": "",
"branch_identical_icon": "≡",
"cherry_pick_icon": " ",
"commit_icon": " ",
"display_stash_count": true,
"display_upstream_icon": true,
"git_icon": "",
"github_icon": "",
"gitlab_icon": "",
"local_staged_icon": "",
"local_working_icon": "",
"merge_icon": " ",
"rebase_icon": " ",
"stash_count_icon": " ",
"tag_icon": "笠 "
},
"style": "powerline",
"type": "git"
}
],
"type": "prompt",
"vertical_offset": 0
}
],
"console_title": false,
"final_space": true
}
CONTRIBUTING
guideWhen creating a new segment configuration options are specified as constants, like this for the "Exit" segment:
const (
//DisplayExitCode shows or hides the error code
DisplayExitCode Property = "display_exit_code"
//AlwaysEnabled decides whether or not to always display the exitcode info
AlwaysEnabled Property = "always_enabled"
//ErrorColor specify a different foreground color for the error text when using always_show = true
ErrorColor Property = "error_color"
)
The challenge is that since all the segments are in the same package, the constants defined here (AlwaysEnabled
) which appear to be per-segment actually aren't. If I wanted a property for a different segment to have an always_enabled
configuration option I'd have to either:
MySegmentAlwaysEnabled
; orMaybe that first option is fine, but it seems weird that some of the segments would need a prefix for their constants but there wouldn't be a convention across all the segments.
I'm not sure what the best solution to this is. Since Go doesn't have a notion of file-scoped variables or constant structs, I'd guess the options are:
always_enabled
vs enable_always
or something because everyone would be using the same constant for the same intent.I didn't know what the preference here was so I figured I'd open an issue and ask. I'd be happy to PR an update if it sounds like some refactoring needs to be done. And if not, I'm glad I asked. 😄
Aside: Thanks for your patience and help with the issues and PRs I'm throwing your way. I'm pretty excited about this new OMP version and it's helping me bring up my Go skills.
CONTRIBUTING
guideThere is too much latency compared to oh-my-posh2, especially when
typing the clear
command.
clear
command in the terminal.Expected behavior:
Little to no latency.
Actual behavior:
Some latency.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.