Skip to content

Commit

Permalink
Allow node indicator to be overridden
Browse files Browse the repository at this point in the history
This commit sets up a pattern for declaring and overriding segment-specific indicators via, e.g., configuration such as:

```json
{
  "modules": [ "perms", "cwd", "node", "git", "jobs", "root" ],
  "mode": "mjg",
  "modes": {
    "mjg": {
      "NodeIndicator":    "\uE781"
    }
  }
}
```
  • Loading branch information
mjgiarlo committed Feb 23, 2022
1 parent 712a3a2 commit f708b82
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ var defaults = Config{
RepoStashed: "\u2691",

VenvIndicator: "\uE235",
NodeIndicator: "\u2B22",
},
"patched": {
Lock: "\uE0A2",
Expand All @@ -104,6 +105,7 @@ var defaults = Config{
RepoStashed: "\u2691",

VenvIndicator: "\uE235",
NodeIndicator: "\u2B22",
},
"flat": {
RepoDetached: "\u2693",
Expand All @@ -116,6 +118,7 @@ var defaults = Config{
RepoStashed: "\u2691",

VenvIndicator: "\uE235",
NodeIndicator: "\u2B22",
},
},
Shells: ShellMap{
Expand Down
4 changes: 2 additions & 2 deletions segment-node.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func segmentNode(p *powerline) []pwl.Segment {
if nodeVersion != "" {
segments = append(segments, pwl.Segment{
Name: "node",
Content: "\u2B22 " + nodeVersion,
Content: p.symbols.NodeIndicator + " " + nodeVersion,
Foreground: p.theme.NodeVersionFg,
Background: p.theme.NodeVersionBg,
})
Expand All @@ -63,7 +63,7 @@ func segmentNode(p *powerline) []pwl.Segment {
if packageVersion != "" {
segments = append(segments, pwl.Segment{
Name: "node-segment",
Content: packageVersion + " \u2B22",
Content: packageVersion + " " + p.symbols.NodeIndicator,
Foreground: p.theme.NodeFg,
Background: p.theme.NodeBg,
})
Expand Down
1 change: 1 addition & 0 deletions themes.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type SymbolTemplate struct {
RepoStashed string

VenvIndicator string
NodeIndicator string
}

// Theme definitions
Expand Down

0 comments on commit f708b82

Please sign in to comment.