diff --git a/src/segments/path.go b/src/segments/path.go index 9a626254..c3d0a674 100644 --- a/src/segments/path.go +++ b/src/segments/path.go @@ -82,6 +82,10 @@ const ( FolderFormat properties.Property = "folder_format" // format to use on the first and last folder of the path EdgeFormat properties.Property = "edge_format" + // format to use on first folder of the path + LeftFormat properties.Property = "left_format" + // format to use on the last folder of the path + RightFormat properties.Property = "right_format" // GitDirFormat format to use on the git directory GitDirFormat properties.Property = "gitdir_format" ) @@ -622,7 +626,10 @@ func (pt *Path) colorizePath(root string, elements []string) string { folderSeparator := pt.getFolderSeparator() colorSeparator := pt.props.GetBool(CycleFolderSeparator, false) folderFormat := pt.props.GetString(FolderFormat, "%s") + edgeFormat := pt.props.GetString(EdgeFormat, folderFormat) + leftFormat := pt.props.GetString(LeftFormat, edgeFormat) + rightFormat := pt.props.GetString(RightFormat, edgeFormat) colorizeElement := func(element string) string { if skipColorize || len(element) == 0 { @@ -635,7 +642,7 @@ func (pt *Path) colorizePath(root string, elements []string) string { } if len(elements) == 0 { - root := fmt.Sprintf(edgeFormat, root) + root := fmt.Sprintf(leftFormat, root) return colorizeElement(root) } @@ -648,7 +655,7 @@ func (pt *Path) colorizePath(root string, elements []string) string { var builder strings.Builder - root = fmt.Sprintf(edgeFormat, root) + root = fmt.Sprintf(leftFormat, root) builder.WriteString(colorizeElement(root)) if root != pt.env.PathSeparator() && len(root) != 0 { @@ -662,7 +669,7 @@ func (pt *Path) colorizePath(root string, elements []string) string { format := folderFormat if i == len(elements)-1 { - format = edgeFormat + format = rightFormat } element = fmt.Sprintf(format, element) diff --git a/website/docs/segments/path.mdx b/website/docs/segments/path.mdx index 648e7e37..957a83e4 100644 --- a/website/docs/segments/path.mdx +++ b/website/docs/segments/path.mdx @@ -46,6 +46,8 @@ import Config from "@site/src/components/Config.js"; | `cycle_folder_separator` | `boolean` | colorize the `folder_separator_icon` as well when using a cycle - defaults to `false` | | `folder_format` | `string` | format to use on individual path folders - defaults to `%s` | | `edge_format` | `string` | format to use on the first and last folder of the path - defaults to `%s` | +| `left_format` | `string` | format to use on the firstfolder of the path - defaults to `edge_format` | +| `right_format` | `string` | format to use on the last folder of the path - defaults to `edge_format` | | `gitdir_format` | `string` | format to use for a git root directory - defaults to `` | ## Mapped Locations