feat(path): get parent folder

This commit is contained in:
Jan De Dobbeleer 2022-08-01 07:11:48 +02:00 committed by Jan De Dobbeleer
parent 19a5c65aa1
commit 79e76c8f3f
2 changed files with 6 additions and 0 deletions

View file

@ -6,6 +6,7 @@ import (
"oh-my-posh/properties" "oh-my-posh/properties"
"oh-my-posh/regex" "oh-my-posh/regex"
"oh-my-posh/template" "oh-my-posh/template"
"path/filepath"
"sort" "sort"
"strings" "strings"
) )
@ -107,6 +108,10 @@ func (pt *Path) Enabled() bool {
return true return true
} }
func (pt *Path) Parent() string {
return filepath.Dir(pt.pwd)
}
func (pt *Path) formatWindowsDrive(pwd string) string { func (pt *Path) formatWindowsDrive(pwd string) string {
if pt.env.GOOS() != environment.WindowsPlatform || !strings.HasSuffix(pwd, ":") { if pt.env.GOOS() != environment.WindowsPlatform || !strings.HasSuffix(pwd, ":") {
return pwd return pwd

View file

@ -147,6 +147,7 @@ folders at the same level, so if `C:\projectA\dev` and `C:\projectB\dev` exist,
### Properties ### Properties
- `.Path`: `string` - the current directory (based on the `style` property) - `.Path`: `string` - the current directory (based on the `style` property)
- `.Parent`: `string` - the current directory's parent folder
- `.Location`: `string` - the current directory (raw value) - `.Location`: `string` - the current directory (raw value)
- `.StackCount`: `int` - the stack count - `.StackCount`: `int` - the stack count
- `.Writable`: `boolean` - is the current directory writable by the user or not - `.Writable`: `boolean` - is the current directory writable by the user or not