JanDeDobbeleer / oh-my-posh

The most customisable and low-latency cross platform/shell prompt renderer
https://ohmyposh.dev
MIT License
17.51k stars 2.4k forks source link

Inconsistent/random .Segments.Path.Writable result with v24+ #5813

Closed stanio closed 2 weeks ago

stanio commented 2 weeks ago

Code of Conduct

What happened?

After upgrading from v23.20.3 → v24.0.2, and currently on v24.0.4, I've noticed a .Segments.Path.Writable template condition:

        {
          "style": "diamond",
          "leading_diamond": "\ue0b6",
          "trailing_diamond": "\ue0b0",
          "template": "{{ if .WSL }}WSL at {{ end }}{{.Icon}} ",
          "foreground": "black",
          "background": "magenta",
          "type": "os",
          "background_templates": [
            "{{ if .Root }}red{{ end }}",
            "{{ if not .Segments.Path.Writable }}white{{ end }}"
          ]
        },

stopped working. More accurately it fails to indicate a writable directory more often than it works as expected (white indicates non-writable directory, while purple is normal/writable):

Cmd Bash
cmd bash

Theme

Custom ```jsonc { "$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json", "blocks": [ { "type": "prompt", "alignment": "right", "segments": [ { "properties": { "style": "round" }, "style": "plain", "template": "{{ .FormattedMs }} | ", "foreground": "darkGray", "background": "", "type": "executiontime" }, { "style": "plain", "template": "{{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }}@{{ .HostName }}", "foreground": "green", "background": "", "type": "session" }, { "properties": { "root_icon": "root" }, "style": "plain", "template": " as \uf0e7", "foreground": "red", "background": "", "type": "root" } ] }, { "type": "prompt", "alignment": "left", "segments": [ { "style": "diamond", "leading_diamond": "\ue0b6", "trailing_diamond": "\ue0b0", "template": "{{ if .WSL }}WSL at {{ end }}{{.Icon}} ", "foreground": "black", "background": "magenta", "type": "os", "background_templates": [ "{{ if .Root }}red{{ end }}", "{{ if not .Segments.Path.Writable }}white{{ end }}" ] }, { "properties": { "folder_separator_icon": " \ue0b1 ", "home_icon": "\udb80\udedc ", "max_depth": 4, "style": "agnoster_short" }, "style": "diamond", "leading_diamond": "\ue0b0", "trailing_diamond": "\ue0b0", "template": " {{ path .Path .Location }} ", "foreground": "black", "powerline_symbol": "\ue0b0", "background": "yellow", "type": "path", "alias": "Path" }, { "properties": { "commit_icon": "\uf417 ", "fetch_status": true, "fetch_upstream_icon": true, "fetch_user": true, "tag_icon": "\uf412 ", "untracked_modes": { "*": "no" } }, "style": "diamond", "leading_diamond": "\ue0b0", "trailing_diamond": "\ue0b4", "template": " {{ .UpstreamIcon }} {{ .HEAD }} {{ .BranchStatus }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if and (.Staging.Changed) (.Working.Changed) }} |{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }} {{ .User.Email }}{{ end }} ", "foreground": "black", "background": "cyan", "type": "git" } ], "newline": true }, { "type": "prompt", "alignment": "left", "segments": [ { "style": "plain", "template": "{{ if eq .Shell \"cmd\" }}❯{{ else if .Root }}#{{ else }}${{ end }} ", "foreground": "lightWhite", "background": "", "type": "text" } ], "newline": true } ], "version": 3, "auto_upgrade": true } ```

What OS are you seeing the problem on?

Windows

Which shell are you using?

bash, cmd

Log output

Version: 24.0.4

Shell: cmd (clink v1.7.4.d1920c)

Prompt:

                                                                                                                                    stanio@staniomob
  󰋜  
❯

Segments:

ConsoleTitle(false)                        -   0 ms
Executiontime(false)                       -   0 ms
Session(true)                              -   1 ms
Root(false)                                -   0 ms
Os(true)                                   -   0 ms
Path(true)                                 -   3 ms
Git(false)                                 -  59 ms
Text(true)                                 -   0 ms

Run duration: 67.1103ms

Cache path: C:\Users\stanio\AppData\Local\oh-my-posh

Config path: C:\Users\stanio\AppData\Local\Programs\oh-my-posh\themes\stanio.omp.jsonc

Logs:

[DEBUG] 08:14:02.068 debug.go:50 → debug mode enabled
[DEBUG] 08:14:02.070 debug.go:50 → plain mode enabled
[DEBUG] 08:14:02.070 terminal.go:Getenv:161 → C:\Users\stanio\AppData\Local
[TRACE] 08:14:02.070 terminal.go:Getenv(LOCALAPPDATA) - 570.4µs
[TRACE] 08:14:02.070 terminal.go:CachePath() - 570.4µs
[DEBUG] 08:14:02.070 terminal.go:65 → loading cache file: C:\Users\stanio\AppData\Local\oh-my-posh\omp.cache
[DEBUG] 08:14:02.071 terminal.go:65 → loading cache key: upgrade_check
[TRACE] 08:14:02.071 terminal.go(C:\Users\stanio\AppData\Local\oh-my-posh\omp.cache) - 535.3µs
[DEBUG] 08:14:02.071 terminal.go:Getenv:161 → C:\Users\stanio\AppData\Local
[TRACE] 08:14:02.071 terminal.go:Getenv(LOCALAPPDATA) - 0s
[TRACE] 08:14:02.071 terminal.go:CachePath() - 575.2µs
[DEBUG] 08:14:02.071 terminal.go:65 → loading cache file: C:\Users\stanio\AppData\Local\oh-my-posh\omp.cache.7ad8ac9c-0aed-45f5-a9a4-c55ea590774a
[TRACE] 08:14:02.071 terminal.go(C:\Users\stanio\AppData\Local\oh-my-posh\omp.cache.7ad8ac9c-0aed-45f5-a9a4-c55ea590774a) - 0s
[TRACE] 08:14:02.071 terminal.go:setPromptCount() - 0s
[TRACE] 08:14:02.071 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.072 terminal.go:setPwd:194 → C:\Users\stanio
[TRACE] 08:14:02.072 terminal.go:setPwd() - 564.2µs
[DEBUG] 08:14:02.072 terminal.go:Getenv:161 → C:\Users\stanio\AppData\Local\Programs\oh-my-posh\themes\stanio.omp.jsonc
[TRACE] 08:14:02.072 terminal.go:Getenv(POSH_THEME) - 0s
[DEBUG] 08:14:02.072 terminal.go:ResolveConfigPath:93 → config set using POSH_THEME: C:\Users\stanio\AppData\Local\Programs\oh-my-posh\themes\stanio.omp.jsonc
[TRACE] 08:14:02.072 terminal.go:ResolveConfigPath() - 0s
[TRACE] 08:14:02.072 terminal.go:Init() - 3.5111ms
[TRACE] 08:14:02.072 terminal.go:Shell() - 0s
[TRACE] 08:14:02.072 terminal.go:Flags() - 0s
[TRACE] 08:14:02.073 load.go:loadConfig() - 1.1131ms
[TRACE] 08:14:02.073 terminal.go:Flags() - 0s
[DEBUG] 08:14:02.073 debug.go:60 → terminal program: Windows Terminal
[DEBUG] 08:14:02.073 debug.go:60 → terminal shell: shell
[DEBUG] 08:14:02.073 terminal.go:Getenv:161 → NO DATA
[TRACE] 08:14:02.073 terminal.go:Getenv(OMP_CACHE_DISABLED) - 0s
[TRACE] 08:14:02.074 terminal_windows.go:WindowsRegistryKeyValue(HKEY_CURRENT_USER\Software\Microsoft\Windows\DWM\ColorizationColor) - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.074 terminal_windows.go:WindowsRegistryKeyValue:213 → ColorizationColor(DWORD): 0xC450506C
[TRACE] 08:14:02.074 colors_windows.go:GetAccentColor() - 584.4µs
[TRACE] 08:14:02.074 colors.go:SetAccentColor() - 584.4µs
[TRACE] 08:14:02.074 terminal.go:Shell() - 0s
[DEBUG] 08:14:02.074 terminal.go:Getenv:161 → clink v1.7.4.d1920c
[TRACE] 08:14:02.074 terminal.go:Getenv(POSH_SHELL_VERSION) - 0s
[DEBUG] 08:14:02.074 debug.go:PrintDebug:23 → segment: Title
[TRACE] 08:14:02.074 text.go:Render() - 0s
[TRACE] 08:14:02.074 terminal.go:Flags() - 0s
[DEBUG] 08:14:02.074 terminal.go:Getenv:161 → 8
[TRACE] 08:14:02.074 terminal.go:Getenv(POSH_CURSOR_LINE) - 0s
[DEBUG] 08:14:02.074 terminal.go:Getenv:161 → NO DATA
[TRACE] 08:14:02.074 terminal.go:Getenv(POSH_CURSOR_COLUMN) - 0s
[TRACE] 08:14:02.074 terminal.go:Flags() - 0s
[TRACE] 08:14:02.074 terminal.go:Flags() - 0s
[TRACE] 08:14:02.074 terminal.go:Flags() - 0s
[DEBUG] 08:14:02.074 terminal_windows.go:56 → C:\Users\stanio
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.074 terminal.go:Flags() - 0s
[DEBUG] 08:14:02.074 segment.go:Execute:103 → segment: Root
[TRACE] 08:14:02.074 terminal.go:Flags() - 0s
[DEBUG] 08:14:02.074 terminal_windows.go:56 → C:\Users\stanio
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.074 segment.go:Execute:103 → segment: Executiontime
[DEBUG] 08:14:02.074 terminal_windows.go:56 → C:\Users\stanio
[TRACE] 08:14:02.074 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.074 segment.go:Execute:103 → segment: Session
[TRACE] 08:14:02.074 terminal_windows.go:Root() - 0s
[DEBUG] 08:14:02.074 executiontime.go:Enabled:55 → always_enabled: false
[TRACE] 08:14:02.074 terminal.go:ExecutionTime() - 0s
[DEBUG] 08:14:02.074 terminal.go:Getenv:161 → NO DATA
[TRACE] 08:14:02.074 terminal.go:Getenv(SSH_CONNECTION) - 0s
[DEBUG] 08:14:02.074 executiontime.go:Enabled:57 → threshold: 500.000000
[TRACE] 08:14:02.074 text.go:Render(plain) - 0s
[DEBUG] 08:14:02.074 terminal.go:Getenv:161 → NO DATA
[TRACE] 08:14:02.074 terminal.go:Getenv(SSH_CLIENT) - 0s
[TRACE] 08:14:02.074 terminal_windows.go:Root() - 0s
[TRACE] 08:14:02.075 terminal.go:Shell() - 0s
[TRACE] 08:14:02.075 terminal.go:StatusCodes() - 0s
[TRACE] 08:14:02.075 terminal_windows.go:IsWsl() - 0s
[DEBUG] 08:14:02.075 terminal_windows.go:56 → C:\Users\stanio
[TRACE] 08:14:02.075 terminal_windows.go:IsWsl() - 0s
[TRACE] 08:14:02.075 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.075 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.075 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.075 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.075 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.075 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.075 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.075 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.075 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.075 terminal.go:User:331 → stanio
[TRACE] 08:14:02.075 terminal.go:User() - 0s
[DEBUG] 08:14:02.075 terminal.go:Host:348 → staniomob
[TRACE] 08:14:02.075 terminal.go:Host() - 0s
[TRACE] 08:14:02.075 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.075 terminal.go:Getenv:161 → NO DATA
[TRACE] 08:14:02.075 terminal.go:Getenv(SHLVL) - 0s
[TRACE] 08:14:02.075 terminal.go:TemplateCache() - 1.0762ms
[TRACE] 08:14:02.075 terminal.go:TemplateCache() - 0s
[TRACE] 08:14:02.075 text.go:Render({{ if .SSHSession }} {{ end }}{{ .UserName }}@{{ .HostName }}) - 0s
[TRACE] 08:14:02.075 text.go:Render(plain) - 0s
[TRACE] 08:14:02.075 text.go:Render(plain) - 0s
[DEBUG] 08:14:02.076 terminal_windows.go:TerminalWidth:114 → terminal width: 148
[TRACE] 08:14:02.076 terminal_windows.go:TerminalWidth() - 591.2µs
[TRACE] 08:14:02.076 terminal.go:Shell() - 0s
[TRACE] 08:14:02.076 terminal.go:Shell() - 0s
[TRACE] 08:14:02.076 terminal.go:Flags() - 0s
[DEBUG] 08:14:02.076 terminal_windows.go:56 → C:\Users\stanio
[TRACE] 08:14:02.076 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.076 segment.go:Execute:103 → segment: Git
[TRACE] 08:14:02.076 terminal.go:Flags() - 0s
[TRACE] 08:14:02.076 terminal.go:Flags() - 0s
[TRACE] 08:14:02.076 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.076 terminal_windows.go:56 → C:\Users\stanio
[DEBUG] 08:14:02.076 terminal_windows.go:56 → C:\Users\stanio
[TRACE] 08:14:02.076 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.076 segment.go:Execute:103 → segment: Path
[TRACE] 08:14:02.076 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.076 segment.go:Execute:103 → segment: Os
[TRACE] 08:14:02.076 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.076 path.go:145 → display_cygpath: false
[TRACE] 08:14:02.076 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.076 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.076 os.go:Enabled:33 → 
[TRACE] 08:14:02.076 terminal.go:PathSeparator() - 0s
[TRACE] 08:14:02.076 terminal.go:TemplateCache() - 0s
[TRACE] 08:14:02.076 terminal.go:Shell() - 0s
[TRACE] 08:14:02.076 terminal.go:Shell() - 0s
[TRACE] 08:14:02.076 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.077 path.go:setMappedLocations:552 → mapped_locations_enabled: true
[DEBUG] 08:14:02.077 path.go:setMappedLocations:553 → 
[DEBUG] 08:14:02.077 path.go:setMappedLocations:554 → 
[DEBUG] 08:14:02.077 terminal_windows.go:56 → C:\Users\stanio
[TRACE] 08:14:02.077 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.077 terminal.go:PathSeparator() - 0s
[TRACE] 08:14:02.077 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.077 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.077 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.077 path.go:setMappedLocations:555 → 󰋜
[DEBUG] 08:14:02.078 path.go:setMappedLocations:560 → mapped_locations: map[]
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:PathSeparator() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:PathSeparator() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:Flags() - 0s
[TRACE] 08:14:02.078 terminal.go:TemplateCache() - 0s
[TRACE] 08:14:02.078 text.go:Render({{ if .WSL }}WSL at {{ end }}{{.Icon}} ) - 1.6208ms
[TRACE] 08:14:02.078 text.go:Render({{ if .Root }}red{{ end }}) - 0s
[DEBUG] 08:14:02.078 path.go:colorizePath:728 → cycle: []
[DEBUG] 08:14:02.078 path.go:getFolderSeparator:263 → NO DATA
[DEBUG] 08:14:02.078 path.go:getFolderSeparator:265 →  
[DEBUG] 08:14:02.078 path.go:colorizePath:731 → cycle_folder_separator: false
[DEBUG] 08:14:02.078 path.go:colorizePath:732 → %s
[DEBUG] 08:14:02.078 path.go:colorizePath:734 → %s
[DEBUG] 08:14:02.078 path.go:colorizePath:735 → %s
[DEBUG] 08:14:02.078 path.go:colorizePath:736 → %s
[TRACE] 08:14:02.078 terminal.go:TemplateCache() - 0s
[TRACE] 08:14:02.078 terminal.go:GOOS() - 0s
[TRACE] 08:14:02.078 terminal.go:StackCount() - 0s
[TRACE] 08:14:02.078 text.go:Render({{ if not .Segments.Path.Writable }}white{{ end }}) - 694.6µs
[TRACE] 08:14:02.078 text.go:Render(diamond) - 0s
[TRACE] 08:14:02.078 text.go:Render({{ if .Root }}red{{ end }}) - 0s
[TRACE] 08:14:02.079 text.go:Render({{ if not .Segments.Path.Writable }}white{{ end }}) - 507.8µs
[DEBUG] 08:14:02.079 win32_windows.go:isWriteable:258 → not current user or in group
[DEBUG] 08:14:02.079 win32_windows.go:isWriteable:262 → current user is member of S-1-5-32-544
[DEBUG] 08:14:02.079 win32_windows.go:isWriteable:270 ↓
    WRITE_DAC
    WRITE_OWNER
    SYNCHRONIZE
    DELETE
    READ_CONTROL
[DEBUG] 08:14:02.079 win32_windows.go:isWriteable:272 → user has write access
[TRACE] 08:14:02.079 terminal_windows.go:DirIsWritable() - 1.3476ms
[TRACE] 08:14:02.079 terminal.go:TemplateCache() - 0s
[TRACE] 08:14:02.080 terminal.go:TemplateCache() - 0s
[TRACE] 08:14:02.080 text.go:Render( {{ path .Path .Location }} ) - 451.2µs
[TRACE] 08:14:02.080 text.go:Render(diamond) - 0s
[DEBUG] 08:14:02.135 terminal.go:CommandPath:395 → C:\Program Files\Git\cmd\git.exe
[TRACE] 08:14:02.135 terminal.go:CommandPath(git.exe) - 58.6701ms
[TRACE] 08:14:02.135 terminal.go:HasCommand(git.exe) - 58.6701ms
[DEBUG] 08:14:02.135 git.go:shouldDisplay:326 → fetch_bare_info: false
[DEBUG] 08:14:02.135 terminal.go:ResolveSymlink:287 → C:\Users\stanio
[TRACE] 08:14:02.135 terminal.go:ResolveSymlink(C:\Users\stanio) - 0s
[ERROR] 08:14:02.136 terminal.go:HasParentFilePath:559 → CreateFile .git: The system cannot find the file specified.
[TRACE] 08:14:02.136 terminal.go:HasParentFilePath(.git) - 1.0004ms
[TRACE] 08:14:02.136 text.go:Render(diamond) - 0s
[TRACE] 08:14:02.136 terminal.go:Shell() - 0s
[TRACE] 08:14:02.136 terminal.go:Shell() - 0s
[TRACE] 08:14:02.136 terminal.go:Flags() - 0s
[DEBUG] 08:14:02.136 terminal_windows.go:56 → C:\Users\stanio
[TRACE] 08:14:02.136 terminal.go:GOOS() - 0s
[DEBUG] 08:14:02.136 segment.go:Execute:103 → segment: Text
[TRACE] 08:14:02.136 terminal.go:TemplateCache() - 0s
[TRACE] 08:14:02.136 text.go:Render({{ if eq .Shell "cmd" }}❯{{ else if .Root }}#{{ else }}${{ end }} ) - 0s
[TRACE] 08:14:02.136 text.go:Render(plain) - 0s
[TRACE] 08:14:02.136 terminal.go:Shell() - 0s
[TRACE] 08:14:02.136 terminal.go:Shell() - 0s
[TRACE] 08:14:02.136 terminal.go:Shell() - 0s
[DEBUG] 08:14:02.136 terminal.go:Getenv:161 → C:\Users\stanio\AppData\Local
[TRACE] 08:14:02.136 terminal.go:Getenv(LOCALAPPDATA) - 0s
[TRACE] 08:14:02.136 terminal.go:CachePath() - 0s
[TRACE] 08:14:02.136 terminal.go:Flags() - 0s
stanio commented 2 weeks ago

FWIW, here's the relevant oh-my-posh debug cmd --plain output when in non-writable directory such as C:\Windows\System32:

[TRACE] 08:22:52.934 text.go:Render({{ if not .Segments.Path.Writable }}white{{ end }}) - 0s
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:258 → not current user or in group
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:258 → not current user or in group
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:258 → not current user or in group
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:258 → not current user or in group
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:262 → current user is member of S-1-5-32-544
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:270 ↓
    SYNCHRONIZE
    DELETE
    READ_CONTROL
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:262 → current user is member of S-1-5-32-544
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:270 → GENERIC_ALL
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:262 → current user is member of S-1-5-32-545
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:270 ↓
    SYNCHRONIZE
    READ_CONTROL
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:262 → current user is member of S-1-5-32-545
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:270 ↓
    GENERIC_READ
    GENERIC_EXECUTE
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:258 → not current user or in group
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:258 → not current user or in group
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:258 → not current user or in group
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:258 → not current user or in group
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:258 → not current user or in group
[DEBUG] 08:22:52.934 win32_windows.go:isWriteable:276 → no write access
[TRACE] 08:22:52.934 terminal_windows.go:DirIsWritable() - 998.3µs
[TRACE] 08:22:52.934 terminal.go:TemplateCache() - 0s
JanDeDobbeleer commented 2 weeks ago

@stanio it's not the .Writable property that's incorrect but the fact that we now render this in parallel and cross template properties no longer work reliably in the color templates. I never assumed this would be something would do, it's actually easier to reuse the path segment for this, where it should work as the os segment is rather empty and all properties you use are available to any template before rendering.

stanio commented 2 weeks ago

If I'm getting it right, I'll need to reference .Segments.Os.Icon in a path segment, and I still need to have the os segment defined. Is it possible to have an empty segment?

        {
      "alias": "Os",
          "type": "os",
          "style": "plain",
          "template": ""
        },
        {
          "type": "path",
          "style": "diamond",
          "leading_diamond": "\ue0b6",
          "trailing_diamond": "\ue0b0",
          "template": "{{ if .WSL }}WSL at {{ end }}{{ .Segments.Os.Icon }} ",
          "foreground": "black",
          "background": "magenta",
          "background_templates": [
            "{{ if .Root }}red{{ end }}",
            "{{ if not .Writable }}white{{ end }}"
          ]
        }

An empty os template definition results in the default segment template being used, and a whitespace-only template prevents the cross-reference in the next segment from working.

JanDeDobbeleer commented 2 weeks ago

@stanio I'll check how to do this during lunch. If something is missing, I'll make sure to do a change.

JanDeDobbeleer commented 2 weeks ago

@stanio found another issue while figuring this out and adding support isn't that much of a change. I'll test this a final time tomorrow and will release.

stanio commented 2 weeks ago

@JanDeDobbeleer, thank you for looking into it.

stanio commented 2 weeks ago

In the meantime, I've tried:

        {
          "type": "os",
          "style": "plain",
          "template": " \u0008" // backspace
        },

and (when it is the first on the line):

          "template": "\u000D" // carriage return

effectively achieves an empty segment from which I could cross-reference .Segments.Os.Icon.

JanDeDobbeleer commented 2 weeks ago

@stanio that's pretty smart, I fixed the issue in the meantime in #5820, thanks for noticing this one. I think the solution now covers more use-cases and can also be extended if it turns out people use cross segment properties in other places.

stanio commented 2 weeks ago

Tested with OMP v24.0.8, my original configuration referencing .Segments.Path.Writable from an os segment works as expected.

JanDeDobbeleer commented 2 weeks ago

@stanio thanks for confirming!

stanio commented 2 weeks ago

Stopped working again after updating v24.0.11 → v24.1.0. The wrong .Segments.Path.Writable value appears constant this time. The workaround using an os "template": " \u0008" segment, and referencing .Segments.Os.Icon from a path segment works, though.

JanDeDobbeleer commented 2 weeks ago

@stanio fixed in latest.

stanio commented 2 weeks ago

Thank you. Works again for me using v24.2.1.