diff --git a/src/segments/path.go b/src/segments/path.go index a2f6219d..d768ffff 100644 --- a/src/segments/path.go +++ b/src/segments/path.go @@ -6,6 +6,7 @@ import ( "oh-my-posh/properties" "oh-my-posh/regex" "oh-my-posh/template" + "path/filepath" "sort" "strings" ) @@ -107,6 +108,10 @@ func (pt *Path) Enabled() bool { return true } +func (pt *Path) Parent() string { + return filepath.Dir(pt.pwd) +} + func (pt *Path) formatWindowsDrive(pwd string) string { if pt.env.GOOS() != environment.WindowsPlatform || !strings.HasSuffix(pwd, ":") { return pwd diff --git a/website/docs/segments/path.mdx b/website/docs/segments/path.mdx index 2c15cb47..8bddb8cd 100644 --- a/website/docs/segments/path.mdx +++ b/website/docs/segments/path.mdx @@ -147,6 +147,7 @@ folders at the same level, so if `C:\projectA\dev` and `C:\projectB\dev` exist, ### Properties - `.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) - `.StackCount`: `int` - the stack count - `.Writable`: `boolean` - is the current directory writable by the user or not