feat(template): add parsed SHLVL

This commit is contained in:
Jan De Dobbeleer 2023-04-02 19:10:34 +02:00 committed by Jan De Dobbeleer
parent 3f4f42cc09
commit 8fe6dd2dcf
2 changed files with 7 additions and 0 deletions

View file

@ -189,6 +189,7 @@ type TemplateCache struct {
OS string
WSL bool
PromptCount int
SHLVL int
Segments SegmentsCache
sync.RWMutex
@ -824,6 +825,11 @@ func (env *Shell) TemplateCache() *TemplateCache {
tmplCache.OS = env.Platform()
}
val := env.Getenv("SHLVL")
if shlvl, err := strconv.Atoi(val); err == nil {
tmplCache.SHLVL = shlvl
}
env.tmplCache = tmplCache
return tmplCache
}

View file

@ -20,6 +20,7 @@ offers a few standard properties to work with.
| `.Folder` | `string` | the current working folder |
| `.Shell` | `string` | the current shell name |
| `.ShellVersion` | `string` | the current shell version |
| `.SHLVL` | `int` | the current shell level |
| `.UserName` | `string` | the current user name |
| `.HostName` | `string` | the host name |
| `.Code` | `int` | the last exit code |