mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-11-09 20:44:03 -08:00
feat(template): add .PSWD
This commit is contained in:
parent
69556d6fb6
commit
485f45c496
1
src/cache/template.go
vendored
1
src/cache/template.go
vendored
|
@ -10,6 +10,7 @@ type Template struct {
|
|||
Root bool
|
||||
PWD string
|
||||
AbsolutePWD string
|
||||
PSWD string
|
||||
Folder string
|
||||
Shell string
|
||||
ShellVersion string
|
||||
|
|
|
@ -62,7 +62,7 @@ func (term *Terminal) Init() {
|
|||
|
||||
if term.CmdFlags.Plain {
|
||||
log.Plain()
|
||||
log.Debug("dlain mode enabled")
|
||||
log.Debug("plain mode enabled")
|
||||
}
|
||||
|
||||
initCache := func(fileName string) *cache.File {
|
||||
|
@ -674,6 +674,8 @@ func (term *Terminal) TemplateCache() *cache.Template {
|
|||
tmplCache.AbsolutePWD, _ = term.RunCommand("wslpath", "-m", pwd)
|
||||
}
|
||||
|
||||
tmplCache.PSWD = term.CmdFlags.PSWD
|
||||
|
||||
tmplCache.Folder = Base(term, pwd)
|
||||
if term.GOOS() == WINDOWS && strings.HasSuffix(tmplCache.Folder, ":") {
|
||||
tmplCache.Folder += `\`
|
||||
|
|
|
@ -109,7 +109,11 @@ func (pt *Path) Enabled() bool {
|
|||
pt.setStyle()
|
||||
pwd := pt.env.Pwd()
|
||||
|
||||
pt.Location = strings.ReplaceAll(pt.env.TemplateCache().AbsolutePWD, `\`, `/`)
|
||||
pt.Location = pt.env.TemplateCache().AbsolutePWD
|
||||
if pt.env.GOOS() == runtime.WINDOWS {
|
||||
pt.Location = strings.ReplaceAll(pt.Location, `\`, `/`)
|
||||
}
|
||||
|
||||
pt.StackCount = pt.env.StackCount()
|
||||
pt.Writable = pt.env.DirIsWritable(pwd)
|
||||
return true
|
||||
|
@ -609,7 +613,7 @@ func (pt *Path) normalizePath(path string) string {
|
|||
lastChar = clean[len(clean)-1:][0]
|
||||
}
|
||||
|
||||
if char == '/' && lastChar != 60 { // 60 == <, this is done to ovoid replacing color codes
|
||||
if char == '/' && lastChar != 60 { // 60 == <, this is done to avoid replacing color codes
|
||||
clean = append(clean, 92) // 92 == \
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ var (
|
|||
"Root",
|
||||
"PWD",
|
||||
"AbsolutePWD",
|
||||
"PSWD",
|
||||
"Folder",
|
||||
"Shell",
|
||||
"ShellVersion",
|
||||
|
|
|
@ -22,6 +22,7 @@ it with `.$` to reference it directly.
|
|||
| `.Root` | `boolean` | is the current user root/admin or not |
|
||||
| `.PWD` | `string` | the current working directory (`~` for `$HOME`) |
|
||||
| `.AbsolutePWD` | `string` | the current working directory (unaltered) |
|
||||
| `.PSWD ` | `string` | the current non-filesystem working directory in PowerShell |
|
||||
| `.Folder` | `string` | the current working folder |
|
||||
| `.Shell` | `string` | the current shell name |
|
||||
| `.ShellVersion` | `string` | the current shell version |
|
||||
|
|
Loading…
Reference in a new issue