mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-02 05:41:10 -08:00
feat(path): allow left and right formatting
This commit is contained in:
parent
4e22e4987d
commit
c4e11fe48d
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue