Closed Silic0nS0ldier closed 2 years ago
@Silic0nS0ldier that's because it should be:
oh-my-posh prompt print primary -c ~/.full.omp.json
I'll make sure to not fail on it.
Why did it stop working though, can you share how you initialize the prompt?
function prompt_lite_cmd() {
# Prompt GUI
oh-my-posh --config ~/.lite.omp.json
}
function prompt_full_cmd() {
# Prompt GUI
oh-my-posh --config ~/.full.omp.json
}
PROMPT='$(prompt_lite_cmd)' # single quotes to prevent immediate execution
ASYNC_PROC=0
function precmd() {
function async() {
# save to temp file
printf "%s" "$(prompt_full_cmd)" > "/tmp/zsh_prompt_$$"
# Wait a little while to avoid race conditions
sleep 0.1
# signal parent
kill -s USR1 $$
}
# kill child if necessary
if [[ "${ASYNC_PROC}" != 0 ]]; then
kill -s HUP $ASYNC_PROC >/dev/null 2>&1 || :
fi
# start background computation
async &!
ASYNC_PROC=$!
}
function TRAPUSR1() {
# read from temp file
PROMPT="$(cat /tmp/zsh_prompt_$$)"
# remove the temp file
rm /tmp/zsh_prompt_$$
# reset proc number
ASYNC_PROC=0
# redisplay
zle && zle reset-prompt
# prepare for next
PROMPT='$(prompt_lite_cmd)'
}
There may be a flag or 2 in use making this work.
setopt interactivecomments
setopt prompt_subst # enable command substition in prompt
(( $+functions[add-zsh-hook] )) || autoload -Uz add-zsh-hook
Breaks on 7.38.0
.
Not entirely sure how I managed to rollback to that in homebrew though.
@Silic0nS0ldier why aren't you using our init function? As that's backwards compatible, this will fail for sure with the latest update.
eval "$(oh-my-posh prompt init zsh --config ~/.lite.omp.json)"
Its a variation on https://github.com/JanDeDobbeleer/oh-my-posh/issues/429#issuecomment-791545718
I just this deferred loading approach as I spend most of my day working out of a monolithic git repo where;
git status
~8sgit status -uno
~5sWith watchman as an fsmonitor
this drops to under a second, under ideal conditions. Under poor conditions (e.g. syncing a branch which is over a week old) it can be over a minute.
@Silic0nS0ldier ow, OK. Allow me to adjust it so it's compatible.
function prompt_lite_cmd() {
# Prompt GUI
oh-my-posh prompt print primary --config ~/.lite.oh-my-posh.json --shell zsh
}
function prompt_full_cmd() {
# Prompt GUI
oh-my-posh prompt print primary --config ~/.full.oh-my-posh.json --shell zsh
}
PROMPT='$(prompt_lite_cmd)' # single quotes to prevent immediate execution
ASYNC_PROC=0
function precmd() {
function async() {
# save to temp file
printf "%s" "$(prompt_full_cmd)" > "/tmp/zsh_prompt_$$"
# Wait a little while to avoid race conditions
sleep 0.1
# signal parent
kill -s USR1 $$
}
# kill child if necessary
if [[ "${ASYNC_PROC}" != 0 ]]; then
kill -s HUP $ASYNC_PROC >/dev/null 2>&1 || :
fi
# start background computation
async &!
ASYNC_PROC=$!
}
function TRAPUSR1() {
# read from temp file
PROMPT="$(cat /tmp/zsh_prompt_$$)"
# remove the temp file
rm /tmp/zsh_prompt_$$
# reset proc number
ASYNC_PROC=0
# redisplay
zle && zle reset-prompt
# prepare for next
PROMPT='$(prompt_lite_cmd)'
}
On Windows 11 v7.40.0 throws an error when querying the version. I am now using V7.39.0.
@Marc013 that means you can from the broken 7.37.1, you should only need to reload your shell/terminal to resolve this.
@JanDeDobbeleer, I installed version 7.40.0 (old version was 7.39.0), then I started pwsh and queried the version. This time no error messages 👍
Do know that the previous version I had installed (when I experienced the issue) was V7.35.0 as you can see in the image I provided in my previous message.
@Marc013 I had to revert one change, and it didn't propagate that well to all package systems. So that could also be the issue, but good that 40 is completely compatible, as it should be 😁
Thanks @JanDeDobbeleer, works with the changes for the new version.
Looks like issue got offtrack somewhat, I'll leave closing up to you in case there are things yet to be wrapped up.
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.
Code of Conduct
What happened?
After updating (
brew upgrade
) the prompt no longer rendered.Possibly related (though I have no baseline) is that
oh-my-posh prompt print
crashes with an out of range error.Theme
A custom theme, of which there are 2. A lite version which is quick to load and a fast version which replaces it later on.
.full.omp.json
```json "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "blocks": [ { "alignment": "left", "segments": [ { "background": "#ffe9aa", "foreground": "#100e23", "powerline_symbol": "\ue0b0", "properties": { "template": " \uf0e7 " }, "style": "powerline", "type": "root" }, { "background": "#000", "foreground": "#007ACC", "powerline_symbol": "\ue0b0", "properties": { "template": " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }}@{{ .HostName }} " }, "style": "powerline", "type": "session" }, { "background": "#0c1e25", "foreground": "#007ACC", "powerline_symbol": "\ue0b0", "properties": { "folder_icon": "\uf115", "folder_separator_icon": "/", "style": "full", "template": " {{ .Path }} " }, "style": "powerline", "type": "path" }, { "background": "#21331d", "foreground": "#007ACC", "powerline_symbol": "\ue0b0", "properties": { "display_mode": "always", "template": " \ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} " }, "style": "powerline", "type": "node" }, { "background": "#162c19", "foreground": "#007ACC", "powerline_symbol": "\ue0b0", "properties": { "branch_icon": "\ue0a0 ", "commit_icon": "\uf417 ", "fetch_status": true, "fetch_upstream_icon": false, "template": " {{ .HEAD }} {{ .BranchStatus }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }}{{ if gt .StashCount 0}} \uf692 {{ .StashCount }}{{ end }}{{ if gt .WorktreeCount 0}} \uf1bb {{ .WorktreeCount }}{{ end }} " }, "style": "powerline", "type": "git" } ], "type": "prompt" }, { "alignment": "left", "newline": true, "segments": [ { "foreground": "#007ACC", "properties": { "template": " {{ .CurrentDate | date .Format }} ", "time_format": "15:04:05" }, "style": "plain", "type": "time" }, { "foreground": "#007ACC", "properties": { "template": "\u276f " }, "style": "plain", "type": "text" } ], "type": "prompt" } ], "version": 1 } ```.lite.omp.json
```json { "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "blocks": [ { "alignment": "left", "segments": [ { "background": "#ffe9aa", "foreground": "#100e23", "powerline_symbol": "\ue0b0", "properties": { "template": " \uf0e7 " }, "style": "powerline", "type": "root" }, { "background": "#000", "foreground": "#007ACC", "powerline_symbol": "\ue0b0", "properties": { "template": " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }}@{{ .HostName }} " }, "style": "powerline", "type": "session" }, { "background": "#0c1e25", "foreground": "#007ACC", "powerline_symbol": "\ue0b0", "properties": { "folder_icon": "\uf115", "folder_separator_icon": "/", "style": "full", "template": " {{ .Path }} " }, "style": "powerline", "type": "path" }, { "background": "#21331d", "foreground": "#007ACC", "powerline_symbol": "\ue0b0", "properties": { "display_mode": "always", "template": " \ue718 {{ if .PackageManagerIcon }}{{ .PackageManagerIcon }} {{ end }}{{ .Full }} " }, "style": "powerline", "type": "node" }, { "background": "#ff8080", "foreground": "#ffffff", "powerline_symbol": "\ue0b0", "properties": { "template": " \ue20f{{ if gt .Code 0 }}\uf00d {{ .Meaning }}{{ else }}\uf42e{{ end }} " }, "style": "powerline", "type": "exit" } ], "type": "prompt" }, { "alignment": "left", "newline": true, "segments": [ { "foreground": "#007ACC", "properties": { "template": " {{ .CurrentDate | date .Format }} ", "time_format": "15:04:05" }, "style": "plain", "type": "time" }, { "foreground": "#007ACC", "properties": { "template": "\u276f " }, "style": "plain", "type": "text" } ], "type": "prompt" } ], "version": 1 } ```What OS are you seeing the problem on?
macOS
Which shell are you using?
zsh
Log output
oh-my-posh prompt print debug --shell uni --config="$POSH_THEME"
```shell Version: 7.40.0 Segments: ConsoleTitle(false) - 0 ms - session(true) - 0 ms - jordan@Jordans-MBP path(true) - 0 ms - alpha shell(true) - 0 ms - uni text(true) - 0 ms - no config exit(true) - 0 ms - Run duration: 2.69563ms Cache path: /Users/jordan/.cache/oh-my-posh Logs: 2022/03/15 14:48:43 Flags duration: 277ns, args: 2022/03/15 14:48:43 Flags duration: 65ns, args: 2022/03/15 14:48:43 Shell duration: 131ns, args: 2022/03/15 14:48:43 debug: Getenv 2022/03/15 14:48:43 Getenv duration: 2.768µs, args: OMP_CACHE_DISABLED 2022/03/15 14:48:43 Root duration: 1.141µs, args: 2022/03/15 14:48:43 Shell duration: 114ns, args: 2022/03/15 14:48:43 ErrorCode duration: 92ns, args: 2022/03/15 14:48:43 debug: Getenv 2022/03/15 14:48:43 Getenv duration: 1.693µs, args: WSL_DISTRO_NAME 2022/03/15 14:48:43 IsWsl duration: 4.3µs, args: 2022/03/15 14:48:43 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:48:43 Pwd duration: 42.386µs, args: 2022/03/15 14:48:43 PathSeparator duration: 89ns, args: 2022/03/15 14:48:43 PathSeparator duration: 61ns, args: 2022/03/15 14:48:43 PathSeparator duration: 85ns, args: 2022/03/15 14:48:43 PathSeparator duration: 61ns, args: 2022/03/15 14:48:43 PathSeparator duration: 62ns, args: 2022/03/15 14:48:43 PathSeparator duration: 61ns, args: 2022/03/15 14:48:43 PathSeparator duration: 82ns, args: 2022/03/15 14:48:43 User duration: 345ns, args: 2022/03/15 14:48:43 Host duration: 11.986µs, args: 2022/03/15 14:48:43 GOOS duration: 92ns, args: 2022/03/15 14:48:43 TemplateCache duration: 105.14µs, args: 2022/03/15 14:48:43 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:48:43 Pwd duration: 1.523µs, args: 2022/03/15 14:48:43 debug: Getenv 2022/03/15 14:48:43 Getenv duration: 1.216µs, args: SSH_CONNECTION 2022/03/15 14:48:43 debug: Getenv 2022/03/15 14:48:43 Getenv duration: 932ns, args: SSH_CLIENT 2022/03/15 14:48:43 TemplateCache duration: 177ns, args: 2022/03/15 14:48:43 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:48:43 Pwd duration: 2.1µs, args: 2022/03/15 14:48:43 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:48:43 Pwd duration: 1.112µs, args: 2022/03/15 14:48:43 Flags duration: 78ns, args: 2022/03/15 14:48:43 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:48:43 Pwd duration: 936ns, args: 2022/03/15 14:48:43 GOOS duration: 85ns, args: 2022/03/15 14:48:43 GOOS duration: 68ns, args: 2022/03/15 14:48:43 PathSeparator duration: 81ns, args: 2022/03/15 14:48:43 PathSeparator duration: 60ns, args: 2022/03/15 14:48:43 PathSeparator duration: 60ns, args: 2022/03/15 14:48:43 PathSeparator duration: 60ns, args: 2022/03/15 14:48:43 PathSeparator duration: 82ns, args: 2022/03/15 14:48:43 PathSeparator duration: 59ns, args: 2022/03/15 14:48:43 PathSeparator duration: 60ns, args: 2022/03/15 14:48:43 PathSeparator duration: 60ns, args: 2022/03/15 14:48:43 GOOS duration: 62ns, args: 2022/03/15 14:48:43 debug: Getenv 2022/03/15 14:48:43 Getenv duration: 1.255µs, args: WSL_DISTRO_NAME 2022/03/15 14:48:43 IsWsl duration: 3.403µs, args: 2022/03/15 14:48:43 StackCount duration: 115ns, args: 2022/03/15 14:48:43 TemplateCache duration: 152ns, args: 2022/03/15 14:48:43 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:48:43 Pwd duration: 1.643µs, args: 2022/03/15 14:48:43 Shell duration: 84ns, args: 2022/03/15 14:48:43 TemplateCache duration: 143ns, args: 2022/03/15 14:48:43 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:48:43 Pwd duration: 1.71µs, args: 2022/03/15 14:48:43 TemplateCache duration: 111ns, args: 2022/03/15 14:48:43 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:48:43 Pwd duration: 4.035µs, args: 2022/03/15 14:48:43 ErrorCode duration: 83ns, args: 2022/03/15 14:48:43 TemplateCache duration: 121ns, args: 2022/03/15 14:48:43 TemplateCache duration: 152ns, args: 2022/03/15 14:48:43 debug: Getenv 2022/03/15 14:48:43 Getenv duration: 1.993µs, args: XDG_CACHE_HOME 2022/03/15 14:48:43 CachePath duration: 32.38µs, args: ```oh-my-posh prompt print debug --shell uni --config=~/.full.omp.json
```shell Version: 7.40.0 Segments: ConsoleTitle(false) - 0 ms - root(false) - 0 ms - session(true) - 0 ms - jordan@Jordans-MBP path(true) - 0 ms - ~/source/canva-repos/canva/alpha node(true) - 1542 ms - 17.7.1 git(true) - 10389 ms - jordan-mele_fix-annotate-failures ≡ time(true) - 0 ms - 14:49:35 text(true) - 1 ms - ❯ Run duration: 11.934909074s Cache path: /Users/jordan/.cache/oh-my-posh Logs: 2022/03/15 14:49:23 Flags duration: 183ns, args: 2022/03/15 14:49:23 Flags duration: 214ns, args: 2022/03/15 14:49:23 Shell duration: 137ns, args: 2022/03/15 14:49:23 debug: Getenv 2022/03/15 14:49:23 Getenv duration: 5.05µs, args: OMP_CACHE_DISABLED 2022/03/15 14:49:23 Root duration: 1.062µs, args: 2022/03/15 14:49:23 Shell duration: 151ns, args: 2022/03/15 14:49:23 ErrorCode duration: 91ns, args: 2022/03/15 14:49:23 debug: Getenv 2022/03/15 14:49:23 Getenv duration: 1.744µs, args: WSL_DISTRO_NAME 2022/03/15 14:49:23 IsWsl duration: 11.823µs, args: 2022/03/15 14:49:23 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:23 Pwd duration: 45.5µs, args: 2022/03/15 14:49:23 PathSeparator duration: 90ns, args: 2022/03/15 14:49:23 PathSeparator duration: 61ns, args: 2022/03/15 14:49:23 PathSeparator duration: 61ns, args: 2022/03/15 14:49:23 PathSeparator duration: 61ns, args: 2022/03/15 14:49:23 PathSeparator duration: 59ns, args: 2022/03/15 14:49:23 PathSeparator duration: 61ns, args: 2022/03/15 14:49:23 PathSeparator duration: 61ns, args: 2022/03/15 14:49:23 User duration: 260ns, args: 2022/03/15 14:49:23 Host duration: 11.226µs, args: 2022/03/15 14:49:23 GOOS duration: 88ns, args: 2022/03/15 14:49:23 TemplateCache duration: 106.903µs, args: 2022/03/15 14:49:23 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:23 Pwd duration: 1.579µs, args: 2022/03/15 14:49:23 Root duration: 818ns, args: 2022/03/15 14:49:23 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:23 Pwd duration: 1.177µs, args: 2022/03/15 14:49:23 debug: Getenv 2022/03/15 14:49:23 Getenv duration: 1.192µs, args: SSH_CONNECTION 2022/03/15 14:49:23 debug: Getenv 2022/03/15 14:49:23 Getenv duration: 982ns, args: SSH_CLIENT 2022/03/15 14:49:23 TemplateCache duration: 242ns, args: 2022/03/15 14:49:23 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:23 Pwd duration: 2.363µs, args: 2022/03/15 14:49:23 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:23 Pwd duration: 1.14µs, args: 2022/03/15 14:49:23 Flags duration: 92ns, args: 2022/03/15 14:49:23 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:23 Pwd duration: 873ns, args: 2022/03/15 14:49:23 GOOS duration: 102ns, args: 2022/03/15 14:49:23 GOOS duration: 80ns, args: 2022/03/15 14:49:23 PathSeparator duration: 111ns, args: 2022/03/15 14:49:23 GOOS duration: 60ns, args: 2022/03/15 14:49:23 debug: Getenv 2022/03/15 14:49:23 Getenv duration: 1.41µs, args: WSL_DISTRO_NAME 2022/03/15 14:49:23 IsWsl duration: 3.944µs, args: 2022/03/15 14:49:23 StackCount duration: 123ns, args: 2022/03/15 14:49:23 TemplateCache duration: 153ns, args: 2022/03/15 14:49:23 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:23 Pwd duration: 1.542µs, args: 2022/03/15 14:49:23 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:23 Pwd duration: 1.033µs, args: 2022/03/15 14:49:23 HasCommand duration: 786.065µs, args: node 2022/03/15 14:49:25 debug: RunCommand v17.7.1 2022/03/15 14:49:25 RunCommand duration: 1.540297153s, args: node --version 2022/03/15 14:49:25 TemplateCache duration: 293ns, args: 2022/03/15 14:49:25 error: FileContent open .nvmrc: no such file or directory 2022/03/15 14:49:25 FileContent duration: 38.939µs, args: .nvmrc 2022/03/15 14:49:25 TemplateCache duration: 254ns, args: 2022/03/15 14:49:25 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:25 Pwd duration: 2.418µs, args: 2022/03/15 14:49:25 debug: Getenv 2022/03/15 14:49:25 Getenv duration: 1.618µs, args: WSL_DISTRO_NAME 2022/03/15 14:49:25 IsWsl duration: 4.165µs, args: 2022/03/15 14:49:25 GOOS duration: 86ns, args: 2022/03/15 14:49:25 HasCommand duration: 90.693µs, args: git 2022/03/15 14:49:25 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:25 Pwd duration: 1.219µs, args: 2022/03/15 14:49:25 HasParentFilePath duration: 11.227µs, args: .git 2022/03/15 14:49:25 FileContent duration: 87.801µs, args: /Users/jordan/source/canva-repos/canva/alpha/.git 2022/03/15 14:49:25 FileContent duration: 64.051µs, args: /Users/jordan/source/canva-repos/canva/.canva/.git/worktrees/alpha/gitdir 2022/03/15 14:49:35 debug: RunCommand # branch.oid 6c3a0c05be22287eb83a58189a1fd53ede8793e4 # branch.head jordan-mele_fix-annotate-failures # branch.upstream origin/jordan-mele_fix-annotate-failures # branch.ab +0 -0 2022/03/15 14:49:35 RunCommand duration: 10.387642375s, args: git -C /Users/jordan/source/canva-repos/canva/alpha/ --no-optional-locks -c core.quotepath=false -c color.status=false status -unormal --branch --porcelain=2 2022/03/15 14:49:35 HasFolder duration: 10.08µs, args: /Users/jordan/source/canva-repos/canva/.canva/.git/worktrees/alpha/rebase-merge 2022/03/15 14:49:35 HasFolder duration: 3.809µs, args: /Users/jordan/source/canva-repos/canva/.canva/.git/worktrees/alpha/rebase-apply 2022/03/15 14:49:35 PathSeparator duration: 115ns, args: 2022/03/15 14:49:35 HasFilesInDir duration: 21.763µs, args: MERGE_MSG 2022/03/15 14:49:35 PathSeparator duration: 57ns, args: 2022/03/15 14:49:35 HasFilesInDir duration: 6.421µs, args: CHERRY_PICK_HEAD 2022/03/15 14:49:35 PathSeparator duration: 80ns, args: 2022/03/15 14:49:35 HasFilesInDir duration: 5.585µs, args: REVERT_HEAD 2022/03/15 14:49:35 PathSeparator duration: 60ns, args: 2022/03/15 14:49:35 HasFilesInDir duration: 6.894µs, args: sequencer/todo 2022/03/15 14:49:35 TemplateCache duration: 339ns, args: 2022/03/15 14:49:35 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:35 Pwd duration: 2.69µs, args: 2022/03/15 14:49:35 TemplateCache duration: 155ns, args: 2022/03/15 14:49:35 debug: Pwd /Users/jordan/source/canva-repos/canva/alpha 2022/03/15 14:49:35 Pwd duration: 1.759µs, args: 2022/03/15 14:49:35 TemplateCache duration: 256ns, args: 2022/03/15 14:49:35 debug: Getenv 2022/03/15 14:49:35 Getenv duration: 2.341µs, args: XDG_CACHE_HOME 2022/03/15 14:49:35 CachePath duration: 1.961101ms, args: ```