From a732dc8f02a3408df41f53dae558fef1b92df9ba Mon Sep 17 00:00:00 2001 From: CJ Vaughter Date: Tue, 3 Nov 2020 17:49:39 -0600 Subject: [PATCH] Added config file support --- config.go | 100 ++ defaults.go | 3169 ++++++++++++++++++----------------- main.go | 178 +- powerline.go | 126 +- segment-cwd.go | 30 +- segment-duration.go | 8 +- segment-exitcode.go | 8 +- segment-git.go | 78 +- segment-hostname.go | 8 +- segment-kube.go | 4 +- segment-readonly.go | 2 +- segment-readonly_windows.go | 2 +- segment-root.go | 4 +- segment-shellvar.go | 4 +- segment-ssh.go | 6 +- segment-subversion.go | 14 +- segment-termtitle.go | 4 +- segment-username.go | 4 +- segment-virtualenv.go | 4 +- themes.go | 2 +- 20 files changed, 1992 insertions(+), 1763 deletions(-) create mode 100644 config.go diff --git a/config.go b/config.go new file mode 100644 index 00000000..ed3bded9 --- /dev/null +++ b/config.go @@ -0,0 +1,100 @@ +package main + +import ( + "os" + "path/filepath" + "io/ioutil" + "encoding/json" +) + +type SymbolMap map[string]SymbolTemplate +type ShellMap map[string]ShellInfo +type ThemeMap map[string]Theme +type AliasMap map[string]string + +type Config struct { + CwdMode string `json:"cwd-mode"` + CwdMaxDepth int `json:"cwd-max-depth"` + CwdMaxDirSize int `json:"cwd-max-dir-size"` + ColorizeHostname bool `json:"colorize-hostname"` + HostnameOnlyIfSSH bool `json:"hostname-only-if-ssh"` + SshAlternateIcon bool `json:"alternate-ssh-icon"` + EastAsianWidth bool `json:"east-asian-width"` + PromptOnNewLine bool `json:"newline"` + StaticPromptIndicator bool `json:"static-prompt-indicator"` + VenvNameSizeLimit int `json:"venv-name-size-limit"` + GitAssumeUnchangedSize int64 `json:"git-assume-unchanged-size"` + GitDisableStats []string `json:"git-disable-stats"` + GitMode string `json:"git-mode"` + Mode string `json:"mode"` + Theme string `json:"theme"` + Shell string `json:"shell"` + Modules []string `json:"modules"` + ModulesRight []string `json:"modules-right"` + Priority []string `json:"priority"` + MaxWidthPercentage int `json:"max-width-percentage"` + TruncateSegmentWidth int `json:"truncate-segment-width"` + PrevError int `json:"-"` + NumericExitCodes bool `json:"numeric-exit-codes"` + IgnoreRepos []string `json:"ignore-repos"` + ShortenGKENames bool `json:"shorten-gke-names"` + ShortenEKSNames bool `json:"shorten-eks-names"` + ShellVar string `json:"shell-var"` + ShellVarNoWarnEmpty bool `json:"shell-var-no-warn-empty"` + TrimADDomain bool `json:"trim-ad-domain"` + PathAliases AliasMap `json:"path-aliases"` + Duration string `json:"-"` + DurationMin string `json:"duration-min"` + Eval bool `json:"eval"` + Condensed bool `json:"condensed"` + Modes SymbolMap `json:"modes"` + Shells ShellMap `json:"shells"` + Themes ThemeMap `json:"themes"` +} + +func (mode *SymbolTemplate) UnmarshalJSON(data []byte) error { + type Alias SymbolTemplate + tmp := defaults.Modes[defaults.Mode] + err := json.Unmarshal(data, (*Alias)(&tmp)) + if err == nil { + *mode = tmp + } + return err +} + +func (theme *Theme) UnmarshalJSON(data []byte) error { + type Alias Theme + tmp := defaults.Themes[defaults.Theme] + err := json.Unmarshal(data, (*Alias)(&tmp)) + if err == nil { + *theme = tmp + } + return err +} + +func configPath() string { + home, _ := os.UserHomeDir() + return filepath.Join(home, ".config", "powerline-go", "config.json") +} + +func (cfg *Config) Load() error { + path := configPath() + file, err := ioutil.ReadFile(path) + if err != nil { + return nil // fail silently + } + return json.Unmarshal(file, cfg) +} + +func (cfg *Config) Save() error { + path := configPath() + tmp := cfg + tmp.Themes = map[string]Theme{} + tmp.Modes = map[string]SymbolTemplate{} + tmp.Shells = map[string]ShellInfo{} + data, err := json.MarshalIndent(tmp, "", " ") + if err != nil { + return err + } + return ioutil.WriteFile(path, data, 0644) +} diff --git a/defaults.go b/defaults.go index 2676ed14..da7a60b5 100644 --- a/defaults.go +++ b/defaults.go @@ -1,1569 +1,1628 @@ package main -var symbolTemplates = map[string]Symbols{ - "compatible": { - Lock: "RO", - Network: "SSH", - NetworkAlternate: "SSH", - Separator: "\u25B6", - SeparatorThin: "\u276F", - SeparatorReverse: "\u25C0", - SeparatorReverseThin: "\u276E", - - RepoDetached: "\u2693", - RepoAhead: "\u2B06", - RepoBehind: "\u2B07", - RepoStaged: "\u2714", - RepoNotStaged: "\u270E", - RepoUntracked: "+", - RepoConflicted: "\u273C", - RepoStashed: "\u2691", - - VenvIndicator: "\uE235", - }, - "patched": { - Lock: "\uE0A2", - Network: "\u260E", - NetworkAlternate: "\uE0A2", - Separator: "\uE0B0", - SeparatorThin: "\uE0B1", - SeparatorReverse: "\uE0B2", - SeparatorReverseThin: "\uE0B3", - - RepoBranch: "\uE0A0", - RepoDetached: "\u2693", - RepoAhead: "\u2B06", - RepoBehind: "\u2B07", - RepoStaged: "\u2714", - RepoNotStaged: "\u270E", - RepoUntracked: "+", - RepoConflicted: "\u273C", - RepoStashed: "\u2691", - - VenvIndicator: "\uE235", - }, - "flat": { - RepoDetached: "\u2693", - RepoAhead: "\u2B06", - RepoBehind: "\u2B07", - RepoStaged: "\u2714", - RepoNotStaged: "\u270E", - RepoUntracked: "+", - RepoConflicted: "\u273C", - RepoStashed: "\u2691", - - VenvIndicator: "\uE235", - }, -} - -var shellInfos = map[string]ShellInfo{ - "bash": { - colorTemplate: "\\[\\e%s\\]", - rootIndicator: "\\$", - escapedBackslash: `\\\\`, - escapedBacktick: "\\`", - escapedDollar: `\$`, - evalPromptPrefix: `PS1="`, - evalPromptSuffix: `"`, +var defaults = Config{ + CwdMode: "fancy", + CwdMaxDepth: 5, + CwdMaxDirSize: -1, + ColorizeHostname: false, + HostnameOnlyIfSSH: false, + SshAlternateIcon: false, + EastAsianWidth: false, + PromptOnNewLine: false, + StaticPromptIndicator: false, + VenvNameSizeLimit: 0, + GitAssumeUnchangedSize: 2048, + GitDisableStats: []string{}, + GitMode: "fancy", + Mode: "patched", + Theme: "default", + Shell: "autodetect", + Modules: []string{ + "venv", + "user", + "host", + "ssh", + "cwd", + "perms", + "git", + "hg", + "jobs", + "exit", + "root", }, - "zsh": { - colorTemplate: "%%{\u001b%s%%}", - rootIndicator: "%#", - escapedBackslash: `\\`, - escapedBacktick: "\\`", - escapedDollar: `\$`, - evalPromptPrefix: `PROMPT="`, - evalPromptSuffix: `"`, - evalPromptRightPrefix: `RPROMPT="`, - evalPromptRightSuffix: `"`, + ModulesRight: []string{}, + Priority: []string{ + "root", + "cwd", + "user", + "host", + "ssh", + "perms", + "git-branch", + "git-status", + "hg", + "jobs", + "exit", + "cwd-path", }, - "bare": { - colorTemplate: "%s", - rootIndicator: "$", - escapedBackslash: `\`, - escapedBacktick: "`", - escapedDollar: `$`, + MaxWidthPercentage: 0, + TruncateSegmentWidth: 16, + PrevError: 0, + NumericExitCodes: false, + IgnoreRepos: []string{}, + ShortenGKENames: false, + ShortenEKSNames: false, + ShellVar: "", + ShellVarNoWarnEmpty: false, + TrimADDomain: false, + PathAliases: AliasMap{}, + Duration: "", + DurationMin: "0", + Eval: false, + Condensed: false, + Modes: SymbolMap{ + "compatible": { + Lock: "RO", + Network: "SSH", + NetworkAlternate: "SSH", + Separator: "\u25B6", + SeparatorThin: "\u276F", + SeparatorReverse: "\u25C0", + SeparatorReverseThin: "\u276E", + + RepoDetached: "\u2693", + RepoAhead: "\u2B06", + RepoBehind: "\u2B07", + RepoStaged: "\u2714", + RepoNotStaged: "\u270E", + RepoUntracked: "+", + RepoConflicted: "\u273C", + RepoStashed: "\u2691", + + VenvIndicator: "\uE235", + }, + "patched": { + Lock: "\uE0A2", + Network: "\u260E", + NetworkAlternate: "\uE0A2", + Separator: "\uE0B0", + SeparatorThin: "\uE0B1", + SeparatorReverse: "\uE0B2", + SeparatorReverseThin: "\uE0B3", + + RepoBranch: "\uE0A0", + RepoDetached: "\u2693", + RepoAhead: "\u2B06", + RepoBehind: "\u2B07", + RepoStaged: "\u2714", + RepoNotStaged: "\u270E", + RepoUntracked: "+", + RepoConflicted: "\u273C", + RepoStashed: "\u2691", + + VenvIndicator: "\uE235", + }, + "flat": { + RepoDetached: "\u2693", + RepoAhead: "\u2B06", + RepoBehind: "\u2B07", + RepoStaged: "\u2714", + RepoNotStaged: "\u270E", + RepoUntracked: "+", + RepoConflicted: "\u273C", + RepoStashed: "\u2691", + + VenvIndicator: "\uE235", + }, }, -} - -var themes = map[string]Theme{ - "default": { - Reset: 0xFF, - - DefaultFg: 250, - DefaultBg: 240, - - UsernameFg: 250, - UsernameBg: 240, - UsernameRootBg: 124, - - HostnameFg: 250, - HostnameBg: 238, - - HomeSpecialDisplay: true, - HomeFg: 15, // white - HomeBg: 31, // blueish - AliasFg: 15, // white - AliasBg: 31, // blueish - PathFg: 250, // light grey - PathBg: 237, // dark grey - CwdFg: 254, // nearly-white grey - SeparatorFg: 244, - - ReadonlyFg: 254, - ReadonlyBg: 124, - - SSHFg: 254, - SSHBg: 166, // medium orange - - DockerMachineFg: 177, // light purple - DockerMachineBg: 55, // purple - - KubeClusterFg: 117, - KubeClusterBg: 26, - KubeNamespaceFg: 170, - KubeNamespaceBg: 17, - - WSLMachineFg: 250, // light grey - WSLMachineBg: 238, // dark grey - - DotEnvFg: 15, // white - DotEnvBg: 55, // purple - - AWSFg: 15, // white - AWSBg: 172, // AWS orange - - RepoCleanFg: 0, // black - RepoCleanBg: 148, // a light green color - RepoDirtyFg: 15, // white - RepoDirtyBg: 161, // pink/red - - JobsFg: 39, - JobsBg: 238, - - CmdPassedFg: 15, - CmdPassedBg: 236, - CmdFailedFg: 15, - CmdFailedBg: 161, - - SvnChangesFg: 22, // dark green - SvnChangesBg: 148, - - GCPFg: 117, - GCPBg: 26, - - GitAheadFg: 250, - GitAheadBg: 240, - GitBehindFg: 250, - GitBehindBg: 240, - GitStagedFg: 15, - GitStagedBg: 22, - GitNotStagedFg: 15, - GitNotStagedBg: 130, - GitUntrackedFg: 15, - GitUntrackedBg: 52, - GitConflictedFg: 15, - GitConflictedBg: 9, - GitStashedFg: 15, - GitStashedBg: 20, - - GoenvBg: 38, // approx. Gopher Blue - GoenvFg: 220, // approx. Secondary Yellow - - VirtualEnvFg: 00, - VirtualEnvBg: 35, // a mid-tone green - - VirtualGoFg: 00, - VirtualGoBg: 06, // Golang turquoise - - PerlbrewFg: 00, - PerlbrewBg: 20, // a mid-tone blue - - PlEnvFg: 00, - PlEnvBg: 32, - - TFWsFg: 15, // white - TFWsBg: 26, // blue - - TimeFg: 15, - TimeBg: 236, - - ShellVarFg: 52, - ShellVarBg: 11, - - ShEnvFg: 15, - ShEnvBg: 130, - - NodeFg: 15, - NodeBg: 40, - - LoadFg: 15, - LoadBg: 22, - LoadHighBg: 161, - LoadAvgValue: 5, - LoadThresholdBad: 1.0, - - NixShellFg: 00, - NixShellBg: 69, // a light blue - - DurationFg: 250, - DurationBg: 237, - - HostnameColorizedFgMap: map[uint8]uint8{ - 0: 250, - 1: 250, - 2: 120, - 3: 228, - 4: 250, - 5: 250, - 6: 123, - 7: 238, - 8: 0, - 9: 0, - 10: 0, - 11: 0, - 12: 250, - 13: 0, - 14: 0, - 15: 242, - 16: 250, - 17: 250, - 18: 250, - 19: 189, - 20: 254, - 21: 250, - 22: 83, - 23: 87, - 24: 117, - 25: 188, - 26: 254, - 27: 0, - 28: 120, - 29: 122, - 30: 123, - 31: 159, - 32: 255, - 33: 0, - 34: 157, - 35: 158, - 36: 159, - 37: 159, - 38: 195, - 39: 0, - 40: 194, - 41: 194, - 42: 195, - 43: 195, - 44: 195, - 45: 0, - 46: 0, - 47: 0, - 48: 0, - 49: 0, - 50: 0, - 51: 0, - 52: 250, - 53: 250, - 54: 250, - 55: 189, - 56: 254, - 57: 250, - 58: 227, - 59: 253, - 60: 255, - 61: 0, - 62: 233, - 63: 17, - 64: 192, - 65: 255, - 66: 195, - 67: 232, - 68: 233, - 69: 17, - 70: 193, - 71: 232, - 72: 232, - 73: 232, - 74: 234, - 75: 236, - 76: 194, - 77: 235, - 78: 235, - 79: 235, - 80: 235, - 81: 237, - 82: 0, - 83: 237, - 84: 237, - 85: 237, - 86: 237, - 87: 237, - 88: 250, - 89: 250, - 90: 250, - 91: 189, - 92: 254, - 93: 0, - 94: 222, - 95: 255, - 96: 255, - 97: 232, - 98: 233, - 99: 17, - 100: 228, - 101: 15, - 102: 232, - 103: 233, - 104: 17, - 105: 18, - 106: 229, - 107: 232, - 108: 234, - 109: 234, - 110: 236, - 111: 54, - 112: 230, - 113: 235, - 114: 22, - 115: 237, - 116: 238, - 117: 238, - 118: 0, - 119: 237, - 120: 22, - 121: 23, - 122: 23, - 123: 23, - 124: 252, - 125: 252, - 126: 189, - 127: 189, - 128: 254, - 129: 0, - 130: 223, - 131: 232, - 132: 232, - 133: 232, - 134: 233, - 135: 17, - 136: 229, - 137: 232, - 138: 233, - 139: 234, - 140: 53, - 141: 18, - 142: 229, - 143: 232, - 144: 234, - 145: 236, - 146: 17, - 147: 19, - 148: 230, - 149: 235, - 150: 238, - 151: 22, - 152: 23, - 153: 24, - 154: 0, - 155: 237, - 156: 22, - 157: 2, - 158: 29, - 159: 6, - 160: 254, - 161: 254, - 162: 254, - 163: 254, - 164: 254, - 165: 0, - 166: 255, - 167: 233, - 168: 233, - 169: 234, - 170: 234, - 171: 235, - 172: 230, - 173: 234, - 174: 52, - 175: 235, - 176: 53, - 177: 53, - 178: 230, - 179: 235, - 180: 236, - 181: 52, - 182: 53, - 183: 55, - 184: 230, - 185: 235, - 186: 238, - 187: 58, - 188: 240, - 189: 20, - 190: 0, - 191: 238, - 192: 58, - 193: 64, - 194: 35, - 195: 66, - 196: 0, - 197: 0, - 198: 0, - 199: 0, - 200: 0, - 201: 0, - 202: 0, - 203: 235, - 204: 235, - 205: 235, - 206: 235, - 207: 53, - 208: 0, - 209: 236, - 210: 52, - 211: 237, - 212: 53, - 213: 53, - 214: 0, - 215: 236, - 216: 238, - 217: 1, - 218: 89, - 219: 5, - 220: 0, - 221: 237, - 222: 58, - 223: 95, - 224: 131, - 225: 126, - 226: 0, - 227: 238, - 228: 58, - 229: 3, - 230: 143, - 231: 242, - 232: 250, - 233: 250, - 234: 250, - 235: 250, - 236: 250, - 237: 250, - 238: 251, - 239: 252, - 240: 188, - 241: 254, - 242: 254, - 243: 255, - 244: 0, - 245: 232, - 246: 233, - 247: 234, - 248: 235, - 249: 236, - 250: 237, - 251: 238, - 252: 239, - 253: 240, - 254: 242, - 255: 243, + Shells: ShellMap{ + "bash": { + ColorTemplate: "\\[\\e%s\\]", + RootIndicator: "\\$", + EscapedBackslash: `\\\\`, + EscapedBacktick: "\\`", + EscapedDollar: `\$`, + EvalPromptPrefix: `PS1="`, + EvalPromptSuffix: `"`, + }, + "zsh": { + ColorTemplate: "%%{\u001b%s%%}", + RootIndicator: "%#", + EscapedBackslash: `\\`, + EscapedBacktick: "\\`", + EscapedDollar: `\$`, + EvalPromptPrefix: `PROMPT="`, + EvalPromptSuffix: `"`, + EvalPromptRightPrefix: `RPROMPT="`, + EvalPromptRightSuffix: `"`, + }, + "bare": { + ColorTemplate: "%s", + RootIndicator: "$", + EscapedBackslash: `\`, + EscapedBacktick: "`", + EscapedDollar: `$`, }, }, - "low-contrast": { - Reset: 0xFF, - - DefaultFg: 234, - DefaultBg: 250, - - UsernameFg: 234, - UsernameBg: 250, - UsernameRootBg: 198, - - HostnameFg: 234, - HostnameBg: 252, - - HomeSpecialDisplay: true, - HomeFg: 30, // blueish-green - HomeBg: 15, // white - AliasFg: 30, // blueish-green - AliasBg: 15, // white - PathFg: 234, - PathBg: 254, - CwdFg: 236, - SeparatorFg: 244, - - ReadonlyFg: 124, - ReadonlyBg: 253, - - SSHFg: 166, // medium orange - SSHBg: 254, - - DockerMachineFg: 55, // purple - DockerMachineBg: 177, // light purple - - KubeClusterFg: 117, - KubeClusterBg: 26, - KubeNamespaceFg: 170, - KubeNamespaceBg: 17, - - DotEnvFg: 15, // white - DotEnvBg: 55, // purple + Themes: ThemeMap{ + "default": { + Reset: 0xFF, + + DefaultFg: 250, + DefaultBg: 240, + + UsernameFg: 250, + UsernameBg: 240, + UsernameRootBg: 124, - RepoCleanFg: 232, // black - RepoCleanBg: 230, // light yellow - RepoDirtyFg: 232, // black - RepoDirtyBg: 223, // orange/peach - - JobsFg: 238, - JobsBg: 39, - - CmdPassedFg: 18, - CmdPassedBg: 7, - CmdFailedFg: 254, - CmdFailedBg: 124, - - SvnChangesFg: 148, - SvnChangesBg: 22, // dark green - - GitAheadFg: 240, - GitAheadBg: 250, - GitBehindFg: 240, - GitBehindBg: 251, - GitStagedFg: 22, - GitStagedBg: 15, - GitNotStagedFg: 130, - GitNotStagedBg: 15, - GitUntrackedFg: 52, - GitUntrackedBg: 15, - GitConflictedFg: 9, - GitConflictedBg: 15, - GitStashedFg: 15, - GitStashedBg: 20, - - GoenvBg: 38, // approx. Gopher Blue - GoenvFg: 220, // approx. Secondary Yellow - - VirtualEnvFg: 35, // a mid-tone green - VirtualEnvBg: 254, - - VirtualGoFg: 06, // Golang turquoise - VirtualGoBg: 254, - - PerlbrewFg: 20, // a mid-tone blue - PerlbrewBg: 15, - - PlEnvFg: 20, // a mid-tone blue - PlEnvBg: 15, - - TimeFg: 236, - TimeBg: 15, - - ShEnvFg: 130, - ShEnvBg: 15, - - LoadFg: 15, - LoadBg: 22, - LoadHighBg: 161, - LoadAvgValue: 5, - LoadThresholdBad: 1.0, - - NixShellFg: 69, // a light blue - NixShellBg: 254, - - HostnameColorizedFgMap: map[uint8]uint8{ - 0: 250, - 1: 250, - 2: 120, - 3: 228, - 4: 250, - 5: 250, - 6: 123, - 7: 238, - 8: 0, - 9: 0, - 10: 0, - 11: 0, - 12: 250, - 13: 0, - 14: 0, - 15: 242, - 16: 250, - 17: 250, - 18: 250, - 19: 189, - 20: 254, - 21: 250, - 22: 83, - 23: 87, - 24: 117, - 25: 188, - 26: 254, - 27: 0, - 28: 120, - 29: 122, - 30: 123, - 31: 159, - 32: 255, - 33: 0, - 34: 157, - 35: 158, - 36: 159, - 37: 159, - 38: 195, - 39: 0, - 40: 194, - 41: 194, - 42: 195, - 43: 195, - 44: 195, - 45: 0, - 46: 0, - 47: 0, - 48: 0, - 49: 0, - 50: 0, - 51: 0, - 52: 250, - 53: 250, - 54: 250, - 55: 189, - 56: 254, - 57: 250, - 58: 227, - 59: 253, - 60: 255, - 61: 0, - 62: 233, - 63: 17, - 64: 192, - 65: 255, - 66: 195, - 67: 232, - 68: 233, - 69: 17, - 70: 193, - 71: 232, - 72: 232, - 73: 232, - 74: 234, - 75: 236, - 76: 194, - 77: 235, - 78: 235, - 79: 235, - 80: 235, - 81: 237, - 82: 0, - 83: 237, - 84: 237, - 85: 237, - 86: 237, - 87: 237, - 88: 250, - 89: 250, - 90: 250, - 91: 189, - 92: 254, - 93: 0, - 94: 222, - 95: 255, - 96: 255, - 97: 232, - 98: 233, - 99: 17, - 100: 228, - 101: 15, - 102: 232, - 103: 233, - 104: 17, - 105: 18, - 106: 229, - 107: 232, - 108: 234, - 109: 234, - 110: 236, - 111: 54, - 112: 230, - 113: 235, - 114: 22, - 115: 237, - 116: 238, - 117: 238, - 118: 0, - 119: 237, - 120: 22, - 121: 23, - 122: 23, - 123: 23, - 124: 252, - 125: 252, - 126: 189, - 127: 189, - 128: 254, - 129: 0, - 130: 223, - 131: 232, - 132: 232, - 133: 232, - 134: 233, - 135: 17, - 136: 229, - 137: 232, - 138: 233, - 139: 234, - 140: 53, - 141: 18, - 142: 229, - 143: 232, - 144: 234, - 145: 236, - 146: 17, - 147: 19, - 148: 230, - 149: 235, - 150: 238, - 151: 22, - 152: 23, - 153: 24, - 154: 0, - 155: 237, - 156: 22, - 157: 2, - 158: 29, - 159: 6, - 160: 254, - 161: 254, - 162: 254, - 163: 254, - 164: 254, - 165: 0, - 166: 255, - 167: 233, - 168: 233, - 169: 234, - 170: 234, - 171: 235, - 172: 230, - 173: 234, - 174: 52, - 175: 235, - 176: 53, - 177: 53, - 178: 230, - 179: 235, - 180: 236, - 181: 52, - 182: 53, - 183: 55, - 184: 230, - 185: 235, - 186: 238, - 187: 58, - 188: 240, - 189: 20, - 190: 0, - 191: 238, - 192: 58, - 193: 64, - 194: 35, - 195: 66, - 196: 0, - 197: 0, - 198: 0, - 199: 0, - 200: 0, - 201: 0, - 202: 0, - 203: 235, - 204: 235, - 205: 235, - 206: 235, - 207: 53, - 208: 0, - 209: 236, - 210: 52, - 211: 237, - 212: 53, - 213: 53, - 214: 0, - 215: 236, - 216: 238, - 217: 1, - 218: 89, - 219: 5, - 220: 0, - 221: 237, - 222: 58, - 223: 95, - 224: 131, - 225: 126, - 226: 0, - 227: 238, - 228: 58, - 229: 3, - 230: 143, - 231: 242, - 232: 250, - 233: 250, - 234: 250, - 235: 250, - 236: 250, - 237: 250, - 238: 251, - 239: 252, - 240: 188, - 241: 254, - 242: 254, - 243: 255, - 244: 0, - 245: 232, - 246: 233, - 247: 234, - 248: 235, - 249: 236, - 250: 237, - 251: 238, - 252: 239, - 253: 240, - 254: 242, - 255: 243, + HostnameFg: 250, + HostnameBg: 238, + + HomeSpecialDisplay: true, + HomeFg: 15, // white + HomeBg: 31, // blueish + AliasFg: 15, // white + AliasBg: 31, // blueish + PathFg: 250, // light grey + PathBg: 237, // dark grey + CwdFg: 254, // nearly-white grey + SeparatorFg: 244, + + ReadonlyFg: 254, + ReadonlyBg: 124, + + SSHFg: 254, + SSHBg: 166, // medium orange + + DockerMachineFg: 177, // light purple + DockerMachineBg: 55, // purple + + KubeClusterFg: 117, + KubeClusterBg: 26, + KubeNamespaceFg: 170, + KubeNamespaceBg: 17, + + WSLMachineFg: 250, // light grey + WSLMachineBg: 238, // dark grey + + DotEnvFg: 15, // white + DotEnvBg: 55, // purple + + AWSFg: 15, // white + AWSBg: 172, // AWS orange + + RepoCleanFg: 0, // black + RepoCleanBg: 148, // a light green color + RepoDirtyFg: 15, // white + RepoDirtyBg: 161, // pink/red + + JobsFg: 39, + JobsBg: 238, + + CmdPassedFg: 15, + CmdPassedBg: 236, + CmdFailedFg: 15, + CmdFailedBg: 161, + + SvnChangesFg: 22, // dark green + SvnChangesBg: 148, + + GCPFg: 117, + GCPBg: 26, + + GitAheadFg: 250, + GitAheadBg: 240, + GitBehindFg: 250, + GitBehindBg: 240, + GitStagedFg: 15, + GitStagedBg: 22, + GitNotStagedFg: 15, + GitNotStagedBg: 130, + GitUntrackedFg: 15, + GitUntrackedBg: 52, + GitConflictedFg: 15, + GitConflictedBg: 9, + GitStashedFg: 15, + GitStashedBg: 20, + + GoenvBg: 38, // approx. Gopher Blue + GoenvFg: 220, // approx. Secondary Yellow + + VirtualEnvFg: 00, + VirtualEnvBg: 35, // a mid-tone green + + VirtualGoFg: 00, + VirtualGoBg: 35, + + PerlbrewFg: 00, + PerlbrewBg: 20, // a mid-tone blue + + PlEnvFg: 00, + PlEnvBg: 32, + + TFWsFg: 15, // white + TFWsBg: 26, // blue + + TimeFg: 15, + TimeBg: 236, + + ShellVarFg: 52, + ShellVarBg: 11, + + ShEnvFg: 15, + ShEnvBg: 130, + + NodeFg: 15, + NodeBg: 40, + + LoadFg: 15, + LoadBg: 22, + LoadHighBg: 161, + LoadAvgValue: 5, + LoadThresholdBad: 1.0, + + NixShellFg: 00, + NixShellBg: 69, // a light blue + + DurationFg: 250, + DurationBg: 237, + + HostnameColorizedFgMap: map[uint8]uint8{ + 0: 250, + 1: 250, + 2: 120, + 3: 228, + 4: 250, + 5: 250, + 6: 123, + 7: 238, + 8: 0, + 9: 0, + 10: 0, + 11: 0, + 12: 250, + 13: 0, + 14: 0, + 15: 242, + 16: 250, + 17: 250, + 18: 250, + 19: 189, + 20: 254, + 21: 250, + 22: 83, + 23: 87, + 24: 117, + 25: 188, + 26: 254, + 27: 0, + 28: 120, + 29: 122, + 30: 123, + 31: 159, + 32: 255, + 33: 0, + 34: 157, + 35: 158, + 36: 159, + 37: 159, + 38: 195, + 39: 0, + 40: 194, + 41: 194, + 42: 195, + 43: 195, + 44: 195, + 45: 0, + 46: 0, + 47: 0, + 48: 0, + 49: 0, + 50: 0, + 51: 0, + 52: 250, + 53: 250, + 54: 250, + 55: 189, + 56: 254, + 57: 250, + 58: 227, + 59: 253, + 60: 255, + 61: 0, + 62: 233, + 63: 17, + 64: 192, + 65: 255, + 66: 195, + 67: 232, + 68: 233, + 69: 17, + 70: 193, + 71: 232, + 72: 232, + 73: 232, + 74: 234, + 75: 236, + 76: 194, + 77: 235, + 78: 235, + 79: 235, + 80: 235, + 81: 237, + 82: 0, + 83: 237, + 84: 237, + 85: 237, + 86: 237, + 87: 237, + 88: 250, + 89: 250, + 90: 250, + 91: 189, + 92: 254, + 93: 0, + 94: 222, + 95: 255, + 96: 255, + 97: 232, + 98: 233, + 99: 17, + 100: 228, + 101: 15, + 102: 232, + 103: 233, + 104: 17, + 105: 18, + 106: 229, + 107: 232, + 108: 234, + 109: 234, + 110: 236, + 111: 54, + 112: 230, + 113: 235, + 114: 22, + 115: 237, + 116: 238, + 117: 238, + 118: 0, + 119: 237, + 120: 22, + 121: 23, + 122: 23, + 123: 23, + 124: 252, + 125: 252, + 126: 189, + 127: 189, + 128: 254, + 129: 0, + 130: 223, + 131: 232, + 132: 232, + 133: 232, + 134: 233, + 135: 17, + 136: 229, + 137: 232, + 138: 233, + 139: 234, + 140: 53, + 141: 18, + 142: 229, + 143: 232, + 144: 234, + 145: 236, + 146: 17, + 147: 19, + 148: 230, + 149: 235, + 150: 238, + 151: 22, + 152: 23, + 153: 24, + 154: 0, + 155: 237, + 156: 22, + 157: 2, + 158: 29, + 159: 6, + 160: 254, + 161: 254, + 162: 254, + 163: 254, + 164: 254, + 165: 0, + 166: 255, + 167: 233, + 168: 233, + 169: 234, + 170: 234, + 171: 235, + 172: 230, + 173: 234, + 174: 52, + 175: 235, + 176: 53, + 177: 53, + 178: 230, + 179: 235, + 180: 236, + 181: 52, + 182: 53, + 183: 55, + 184: 230, + 185: 235, + 186: 238, + 187: 58, + 188: 240, + 189: 20, + 190: 0, + 191: 238, + 192: 58, + 193: 64, + 194: 35, + 195: 66, + 196: 0, + 197: 0, + 198: 0, + 199: 0, + 200: 0, + 201: 0, + 202: 0, + 203: 235, + 204: 235, + 205: 235, + 206: 235, + 207: 53, + 208: 0, + 209: 236, + 210: 52, + 211: 237, + 212: 53, + 213: 53, + 214: 0, + 215: 236, + 216: 238, + 217: 1, + 218: 89, + 219: 5, + 220: 0, + 221: 237, + 222: 58, + 223: 95, + 224: 131, + 225: 126, + 226: 0, + 227: 238, + 228: 58, + 229: 3, + 230: 143, + 231: 242, + 232: 250, + 233: 250, + 234: 250, + 235: 250, + 236: 250, + 237: 250, + 238: 251, + 239: 252, + 240: 188, + 241: 254, + 242: 254, + 243: 255, + 244: 0, + 245: 232, + 246: 233, + 247: 234, + 248: 235, + 249: 236, + 250: 237, + 251: 238, + 252: 239, + 253: 240, + 254: 242, + 255: 243, + }, }, - }, - "solarized-dark16": { - Reset: 8, - DefaultFg: 15, - DefaultBg: 4, - UsernameFg: 15, - UsernameBg: 4, - UsernameRootBg: 1, - HostnameFg: 15, - HostnameBg: 0, - HomeSpecialDisplay: false, - HomeFg: 15, - HomeBg: 4, - PathFg: 15, - PathBg: 10, - CwdFg: 15, - SeparatorFg: 15, - ReadonlyFg: 8, - ReadonlyBg: 1, - SSHFg: 8, - SSHBg: 9, - DockerMachineFg: 13, - DockerMachineBg: 55, - DotEnvFg: 15, - DotEnvBg: 55, - RepoCleanFg: 15, - RepoCleanBg: 3, - RepoDirtyFg: 15, - RepoDirtyBg: 5, - JobsFg: 4, - JobsBg: 0, - CmdPassedFg: 15, - CmdPassedBg: 0, - CmdFailedFg: 15, - CmdFailedBg: 5, - SvnChangesFg: 2, - SvnChangesBg: 3, - GitAheadFg: 14, - GitAheadBg: 10, - GitBehindFg: 14, - GitBehindBg: 10, - GitStagedFg: 15, - GitStagedBg: 2, - GitNotStagedFg: 15, - GitNotStagedBg: 9, - GitUntrackedFg: 15, - GitUntrackedBg: 1, - GitConflictedFg: 15, - GitConflictedBg: 1, - GitStashedFg: 15, - GitStashedBg: 4, - GoenvBg: 38, // approx. Gopher Blue - GoenvFg: 220, // approx. Secondary Yellow - VirtualEnvFg: 8, - VirtualEnvBg: 6, - PerlbrewFg: 8, - PerlbrewBg: 4, - PlEnvFg: 8, - PlEnvBg: 4, - TimeFg: 15, - TimeBg: 0, - ShellVarFg: 1, - ShellVarBg: 11, - ShEnvFg: 15, - ShEnvBg: 9, - NodeFg: 15, - NodeBg: 40, - LoadFg: 15, - LoadBg: 2, - LoadHighBg: 5, - LoadAvgValue: 5, - LoadThresholdBad: 1.0, - NixShellFg: 0, - NixShellBg: 4, - HostnameColorizedFgMap: map[uint8]uint8{ - 0: 14, - 1: 14, - 2: 120, - 3: 228, - 4: 14, - 5: 14, - 6: 123, - 7: 0, - 8: 8, - 9: 8, - 10: 8, - 11: 8, - 12: 14, - 13: 8, - 14: 8, - 15: 242, - 16: 14, - 17: 14, - 18: 14, - 19: 189, - 20: 8, - 21: 14, - 22: 83, - 23: 87, - 24: 117, - 25: 188, - 26: 8, - 27: 8, - 28: 120, - 29: 122, - 30: 123, - 31: 159, - 32: 8, - 33: 8, - 34: 157, - 35: 158, - 36: 159, - 37: 159, - 38: 195, - 39: 8, - 40: 194, - 41: 194, - 42: 195, - 43: 195, - 44: 195, - 45: 8, - 46: 8, - 47: 8, - 48: 8, - 49: 8, - 50: 8, - 51: 8, - 52: 14, - 53: 14, - 54: 14, - 55: 189, - 56: 8, - 57: 14, - 58: 227, - 59: 253, - 60: 8, - 61: 8, - 62: 233, - 63: 17, - 64: 192, - 65: 8, - 66: 195, - 67: 232, - 68: 233, - 69: 17, - 70: 193, - 71: 232, - 72: 232, - 73: 232, - 74: 8, - 75: 0, - 76: 194, - 77: 0, - 78: 0, - 79: 0, - 80: 0, - 81: 0, - 82: 8, - 83: 0, - 84: 0, - 85: 0, - 86: 0, - 87: 0, - 88: 14, - 89: 14, - 90: 14, - 91: 189, - 92: 8, - 93: 8, - 94: 222, - 95: 8, - 96: 8, - 97: 232, - 98: 233, - 99: 17, - 100: 228, - 101: 15, - 102: 232, - 103: 233, - 104: 17, - 105: 18, - 106: 229, - 107: 232, - 108: 8, - 109: 8, - 110: 0, - 111: 54, - 112: 15, - 113: 0, - 114: 2, - 115: 0, - 116: 0, - 117: 0, - 118: 8, - 119: 0, - 120: 2, - 121: 23, - 122: 23, - 123: 23, - 124: 252, - 125: 252, - 126: 189, - 127: 189, - 128: 8, - 129: 8, - 130: 223, - 131: 232, - 132: 232, - 133: 232, - 134: 233, - 135: 17, - 136: 229, - 137: 232, - 138: 233, - 139: 8, - 140: 53, - 141: 18, - 142: 229, - 143: 232, - 144: 8, - 145: 0, - 146: 17, - 147: 19, - 148: 15, - 149: 0, - 150: 0, - 151: 2, - 152: 23, - 153: 24, - 154: 8, - 155: 0, - 156: 2, - 157: 2, - 158: 29, - 159: 6, - 160: 8, - 161: 8, - 162: 8, - 163: 8, - 164: 8, - 165: 8, - 166: 8, - 167: 233, - 168: 233, - 169: 8, - 170: 8, - 171: 0, - 172: 15, - 173: 8, - 174: 1, - 175: 0, - 176: 53, - 177: 53, - 178: 15, - 179: 0, - 180: 0, - 181: 1, - 182: 53, - 183: 55, - 184: 15, - 185: 0, - 186: 0, - 187: 58, - 188: 10, - 189: 4, - 190: 8, - 191: 0, - 192: 58, - 193: 2, - 194: 35, - 195: 66, - 196: 8, - 197: 8, - 198: 8, - 199: 8, - 200: 8, - 201: 8, - 202: 8, - 203: 0, - 204: 0, - 205: 0, - 206: 0, - 207: 53, - 208: 8, - 209: 0, - 210: 1, - 211: 0, - 212: 53, - 213: 53, - 214: 8, - 215: 0, - 216: 0, - 217: 1, - 218: 89, - 219: 5, - 220: 8, - 221: 0, - 222: 58, - 223: 95, - 224: 131, - 225: 126, - 226: 8, - 227: 0, - 228: 58, - 229: 3, - 230: 143, - 231: 242, - 232: 14, - 233: 14, - 234: 14, - 235: 14, - 236: 14, - 237: 14, - 238: 251, - 239: 252, - 240: 188, - 241: 8, - 242: 8, - 243: 8, - 244: 8, - 245: 232, - 246: 233, - 247: 8, - 248: 0, - 249: 0, - 250: 0, - 251: 0, - 252: 239, - 253: 10, - 254: 242, - 255: 243, + "low-contrast": { + Reset: 0xFF, + + DefaultFg: 234, + DefaultBg: 250, + + UsernameFg: 234, + UsernameBg: 250, + UsernameRootBg: 198, + + HostnameFg: 234, + HostnameBg: 252, + + HomeSpecialDisplay: true, + HomeFg: 30, // blueish-green + HomeBg: 15, // white + AliasFg: 30, // blueish-green + AliasBg: 15, // white + PathFg: 234, + PathBg: 254, + CwdFg: 236, + SeparatorFg: 244, + + ReadonlyFg: 124, + ReadonlyBg: 253, + + SSHFg: 166, // medium orange + SSHBg: 254, + + DockerMachineFg: 55, // purple + DockerMachineBg: 177, // light purple + + KubeClusterFg: 117, + KubeClusterBg: 26, + KubeNamespaceFg: 170, + KubeNamespaceBg: 17, + + DotEnvFg: 15, // white + DotEnvBg: 55, // purple + + RepoCleanFg: 232, // black + RepoCleanBg: 230, // light yellow + RepoDirtyFg: 232, // black + RepoDirtyBg: 223, // orange/peach + + JobsFg: 238, + JobsBg: 39, + + CmdPassedFg: 18, + CmdPassedBg: 7, + CmdFailedFg: 254, + CmdFailedBg: 124, + + SvnChangesFg: 148, + SvnChangesBg: 22, // dark green + + GitAheadFg: 240, + GitAheadBg: 250, + GitBehindFg: 240, + GitBehindBg: 251, + GitStagedFg: 22, + GitStagedBg: 15, + GitNotStagedFg: 130, + GitNotStagedBg: 15, + GitUntrackedFg: 52, + GitUntrackedBg: 15, + GitConflictedFg: 9, + GitConflictedBg: 15, + GitStashedFg: 15, + GitStashedBg: 20, + + GoenvBg: 38, // approx. Gopher Blue + GoenvFg: 220, // approx. Secondary Yellow + + VirtualEnvFg: 35, // a mid-tone green + VirtualEnvBg: 254, + + VirtualGoFg: 35, + VirtualGoBg: 254, + + PerlbrewFg: 20, // a mid-tone blue + PerlbrewBg: 15, + + PlEnvFg: 20, // a mid-tone blue + PlEnvBg: 15, + + TimeFg: 236, + TimeBg: 15, + + ShEnvFg: 130, + ShEnvBg: 15, + + LoadFg: 15, + LoadBg: 22, + LoadHighBg: 161, + LoadAvgValue: 5, + LoadThresholdBad: 1.0, + + NixShellFg: 69, // a light blue + NixShellBg: 254, + + HostnameColorizedFgMap: map[uint8]uint8{ + 0: 250, + 1: 250, + 2: 120, + 3: 228, + 4: 250, + 5: 250, + 6: 123, + 7: 238, + 8: 0, + 9: 0, + 10: 0, + 11: 0, + 12: 250, + 13: 0, + 14: 0, + 15: 242, + 16: 250, + 17: 250, + 18: 250, + 19: 189, + 20: 254, + 21: 250, + 22: 83, + 23: 87, + 24: 117, + 25: 188, + 26: 254, + 27: 0, + 28: 120, + 29: 122, + 30: 123, + 31: 159, + 32: 255, + 33: 0, + 34: 157, + 35: 158, + 36: 159, + 37: 159, + 38: 195, + 39: 0, + 40: 194, + 41: 194, + 42: 195, + 43: 195, + 44: 195, + 45: 0, + 46: 0, + 47: 0, + 48: 0, + 49: 0, + 50: 0, + 51: 0, + 52: 250, + 53: 250, + 54: 250, + 55: 189, + 56: 254, + 57: 250, + 58: 227, + 59: 253, + 60: 255, + 61: 0, + 62: 233, + 63: 17, + 64: 192, + 65: 255, + 66: 195, + 67: 232, + 68: 233, + 69: 17, + 70: 193, + 71: 232, + 72: 232, + 73: 232, + 74: 234, + 75: 236, + 76: 194, + 77: 235, + 78: 235, + 79: 235, + 80: 235, + 81: 237, + 82: 0, + 83: 237, + 84: 237, + 85: 237, + 86: 237, + 87: 237, + 88: 250, + 89: 250, + 90: 250, + 91: 189, + 92: 254, + 93: 0, + 94: 222, + 95: 255, + 96: 255, + 97: 232, + 98: 233, + 99: 17, + 100: 228, + 101: 15, + 102: 232, + 103: 233, + 104: 17, + 105: 18, + 106: 229, + 107: 232, + 108: 234, + 109: 234, + 110: 236, + 111: 54, + 112: 230, + 113: 235, + 114: 22, + 115: 237, + 116: 238, + 117: 238, + 118: 0, + 119: 237, + 120: 22, + 121: 23, + 122: 23, + 123: 23, + 124: 252, + 125: 252, + 126: 189, + 127: 189, + 128: 254, + 129: 0, + 130: 223, + 131: 232, + 132: 232, + 133: 232, + 134: 233, + 135: 17, + 136: 229, + 137: 232, + 138: 233, + 139: 234, + 140: 53, + 141: 18, + 142: 229, + 143: 232, + 144: 234, + 145: 236, + 146: 17, + 147: 19, + 148: 230, + 149: 235, + 150: 238, + 151: 22, + 152: 23, + 153: 24, + 154: 0, + 155: 237, + 156: 22, + 157: 2, + 158: 29, + 159: 6, + 160: 254, + 161: 254, + 162: 254, + 163: 254, + 164: 254, + 165: 0, + 166: 255, + 167: 233, + 168: 233, + 169: 234, + 170: 234, + 171: 235, + 172: 230, + 173: 234, + 174: 52, + 175: 235, + 176: 53, + 177: 53, + 178: 230, + 179: 235, + 180: 236, + 181: 52, + 182: 53, + 183: 55, + 184: 230, + 185: 235, + 186: 238, + 187: 58, + 188: 240, + 189: 20, + 190: 0, + 191: 238, + 192: 58, + 193: 64, + 194: 35, + 195: 66, + 196: 0, + 197: 0, + 198: 0, + 199: 0, + 200: 0, + 201: 0, + 202: 0, + 203: 235, + 204: 235, + 205: 235, + 206: 235, + 207: 53, + 208: 0, + 209: 236, + 210: 52, + 211: 237, + 212: 53, + 213: 53, + 214: 0, + 215: 236, + 216: 238, + 217: 1, + 218: 89, + 219: 5, + 220: 0, + 221: 237, + 222: 58, + 223: 95, + 224: 131, + 225: 126, + 226: 0, + 227: 238, + 228: 58, + 229: 3, + 230: 143, + 231: 242, + 232: 250, + 233: 250, + 234: 250, + 235: 250, + 236: 250, + 237: 250, + 238: 251, + 239: 252, + 240: 188, + 241: 254, + 242: 254, + 243: 255, + 244: 0, + 245: 232, + 246: 233, + 247: 234, + 248: 235, + 249: 236, + 250: 237, + 251: 238, + 252: 239, + 253: 240, + 254: 242, + 255: 243, + }, }, - }, - "solarized-light16": { - Reset: 0, - DefaultFg: 15, - DefaultBg: 4, - UsernameFg: 15, - UsernameBg: 4, - UsernameRootBg: 1, - HostnameFg: 15, - HostnameBg: 7, - HomeSpecialDisplay: false, - HomeFg: 15, - HomeBg: 4, - PathFg: 15, - PathBg: 10, - CwdFg: 15, - SeparatorFg: 15, - ReadonlyFg: 8, - ReadonlyBg: 1, - SSHFg: 8, - SSHBg: 9, - DockerMachineFg: 13, - DockerMachineBg: 55, - DotEnvFg: 15, - DotEnvBg: 55, - RepoCleanFg: 15, - RepoCleanBg: 3, - RepoDirtyFg: 15, - RepoDirtyBg: 5, - JobsFg: 4, - JobsBg: 0, - CmdPassedFg: 10, - CmdPassedBg: 7, - CmdFailedFg: 15, - CmdFailedBg: 5, - SvnChangesFg: 2, - SvnChangesBg: 3, - GitAheadFg: 14, - GitAheadBg: 10, - GitBehindFg: 14, - GitBehindBg: 10, - GitStagedFg: 15, - GitStagedBg: 2, - GitNotStagedFg: 15, - GitNotStagedBg: 9, - GitUntrackedFg: 15, - GitUntrackedBg: 1, - GitConflictedFg: 15, - GitConflictedBg: 1, - GitStashedFg: 15, - GitStashedBg: 4, - GoenvBg: 38, // approx. Gopher Blue - GoenvFg: 220, // approx. Secondary Yellow - VirtualEnvFg: 8, - VirtualEnvBg: 6, - PerlbrewFg: 8, - PerlbrewBg: 4, - PlEnvFg: 8, - PlEnvBg: 4, - TimeFg: 15, - TimeBg: 0, - ShellVarFg: 1, - ShellVarBg: 11, - ShEnvFg: 15, - ShEnvBg: 9, - NodeFg: 15, - NodeBg: 40, - LoadFg: 15, - LoadBg: 2, - LoadHighBg: 5, - LoadAvgValue: 5, - LoadThresholdBad: 1.0, - NixShellFg: 0, - NixShellBg: 7, - HostnameColorizedFgMap: map[uint8]uint8{ - 0: 14, - 1: 14, - 2: 120, - 3: 228, - 4: 14, - 5: 14, - 6: 123, - 7: 0, - 8: 8, - 9: 8, - 10: 8, - 11: 8, - 12: 14, - 13: 8, - 14: 8, - 15: 242, - 16: 14, - 17: 14, - 18: 14, - 19: 189, - 20: 8, - 21: 14, - 22: 83, - 23: 87, - 24: 117, - 25: 188, - 26: 8, - 27: 8, - 28: 120, - 29: 122, - 30: 123, - 31: 159, - 32: 8, - 33: 8, - 34: 157, - 35: 158, - 36: 159, - 37: 159, - 38: 195, - 39: 8, - 40: 194, - 41: 194, - 42: 195, - 43: 195, - 44: 195, - 45: 8, - 46: 8, - 47: 8, - 48: 8, - 49: 8, - 50: 8, - 51: 8, - 52: 14, - 53: 14, - 54: 14, - 55: 189, - 56: 8, - 57: 14, - 58: 227, - 59: 253, - 60: 8, - 61: 8, - 62: 233, - 63: 17, - 64: 192, - 65: 8, - 66: 195, - 67: 232, - 68: 233, - 69: 17, - 70: 193, - 71: 232, - 72: 232, - 73: 232, - 74: 8, - 75: 0, - 76: 194, - 77: 0, - 78: 0, - 79: 0, - 80: 0, - 81: 0, - 82: 8, - 83: 0, - 84: 0, - 85: 0, - 86: 0, - 87: 0, - 88: 14, - 89: 14, - 90: 14, - 91: 189, - 92: 8, - 93: 8, - 94: 222, - 95: 8, - 96: 8, - 97: 232, - 98: 233, - 99: 17, - 100: 228, - 101: 15, - 102: 232, - 103: 233, - 104: 17, - 105: 18, - 106: 229, - 107: 232, - 108: 8, - 109: 8, - 110: 0, - 111: 54, - 112: 15, - 113: 0, - 114: 2, - 115: 0, - 116: 0, - 117: 0, - 118: 8, - 119: 0, - 120: 2, - 121: 23, - 122: 23, - 123: 23, - 124: 252, - 125: 252, - 126: 189, - 127: 189, - 128: 8, - 129: 8, - 130: 223, - 131: 232, - 132: 232, - 133: 232, - 134: 233, - 135: 17, - 136: 229, - 137: 232, - 138: 233, - 139: 8, - 140: 53, - 141: 18, - 142: 229, - 143: 232, - 144: 8, - 145: 0, - 146: 17, - 147: 19, - 148: 15, - 149: 0, - 150: 0, - 151: 2, - 152: 23, - 153: 24, - 154: 8, - 155: 0, - 156: 2, - 157: 2, - 158: 29, - 159: 6, - 160: 8, - 161: 8, - 162: 8, - 163: 8, - 164: 8, - 165: 8, - 166: 8, - 167: 233, - 168: 233, - 169: 8, - 170: 8, - 171: 0, - 172: 15, - 173: 8, - 174: 1, - 175: 0, - 176: 53, - 177: 53, - 178: 15, - 179: 0, - 180: 0, - 181: 1, - 182: 53, - 183: 55, - 184: 15, - 185: 0, - 186: 0, - 187: 58, - 188: 10, - 189: 4, - 190: 8, - 191: 0, - 192: 58, - 193: 2, - 194: 35, - 195: 66, - 196: 8, - 197: 8, - 198: 8, - 199: 8, - 200: 8, - 201: 8, - 202: 8, - 203: 0, - 204: 0, - 205: 0, - 206: 0, - 207: 53, - 208: 8, - 209: 0, - 210: 1, - 211: 0, - 212: 53, - 213: 53, - 214: 8, - 215: 0, - 216: 0, - 217: 1, - 218: 89, - 219: 5, - 220: 8, - 221: 0, - 222: 58, - 223: 95, - 224: 131, - 225: 126, - 226: 8, - 227: 0, - 228: 58, - 229: 3, - 230: 143, - 231: 242, - 232: 14, - 233: 14, - 234: 14, - 235: 14, - 236: 14, - 237: 14, - 238: 251, - 239: 252, - 240: 188, - 241: 8, - 242: 8, - 243: 8, - 244: 8, - 245: 232, - 246: 233, - 247: 8, - 248: 0, - 249: 0, - 250: 0, - 251: 0, - 252: 239, - 253: 10, - 254: 242, - 255: 243, + "solarized-dark16": { + Reset: 8, + DefaultFg: 15, + DefaultBg: 4, + UsernameFg: 15, + UsernameBg: 4, + UsernameRootBg: 1, + HostnameFg: 15, + HostnameBg: 0, + HomeSpecialDisplay: false, + HomeFg: 15, + HomeBg: 4, + PathFg: 15, + PathBg: 10, + CwdFg: 15, + SeparatorFg: 15, + ReadonlyFg: 8, + ReadonlyBg: 1, + SSHFg: 8, + SSHBg: 9, + DockerMachineFg: 13, + DockerMachineBg: 55, + DotEnvFg: 15, + DotEnvBg: 55, + RepoCleanFg: 15, + RepoCleanBg: 3, + RepoDirtyFg: 15, + RepoDirtyBg: 5, + JobsFg: 4, + JobsBg: 0, + CmdPassedFg: 15, + CmdPassedBg: 0, + CmdFailedFg: 15, + CmdFailedBg: 5, + SvnChangesFg: 2, + SvnChangesBg: 3, + GitAheadFg: 14, + GitAheadBg: 10, + GitBehindFg: 14, + GitBehindBg: 10, + GitStagedFg: 15, + GitStagedBg: 2, + GitNotStagedFg: 15, + GitNotStagedBg: 9, + GitUntrackedFg: 15, + GitUntrackedBg: 1, + GitConflictedFg: 15, + GitConflictedBg: 1, + GitStashedFg: 15, + GitStashedBg: 4, + GoenvBg: 38, // approx. Gopher Blue + GoenvFg: 220, // approx. Secondary Yellow + VirtualEnvFg: 8, + VirtualEnvBg: 6, + PerlbrewFg: 8, + PerlbrewBg: 4, + PlEnvFg: 8, + PlEnvBg: 4, + TimeFg: 15, + TimeBg: 0, + ShellVarFg: 1, + ShellVarBg: 11, + ShEnvFg: 15, + ShEnvBg: 9, + NodeFg: 15, + NodeBg: 40, + LoadFg: 15, + LoadBg: 2, + LoadHighBg: 5, + LoadAvgValue: 5, + LoadThresholdBad: 1.0, + NixShellFg: 0, + NixShellBg: 4, + HostnameColorizedFgMap: map[uint8]uint8{ + 0: 14, + 1: 14, + 2: 120, + 3: 228, + 4: 14, + 5: 14, + 6: 123, + 7: 0, + 8: 8, + 9: 8, + 10: 8, + 11: 8, + 12: 14, + 13: 8, + 14: 8, + 15: 242, + 16: 14, + 17: 14, + 18: 14, + 19: 189, + 20: 8, + 21: 14, + 22: 83, + 23: 87, + 24: 117, + 25: 188, + 26: 8, + 27: 8, + 28: 120, + 29: 122, + 30: 123, + 31: 159, + 32: 8, + 33: 8, + 34: 157, + 35: 158, + 36: 159, + 37: 159, + 38: 195, + 39: 8, + 40: 194, + 41: 194, + 42: 195, + 43: 195, + 44: 195, + 45: 8, + 46: 8, + 47: 8, + 48: 8, + 49: 8, + 50: 8, + 51: 8, + 52: 14, + 53: 14, + 54: 14, + 55: 189, + 56: 8, + 57: 14, + 58: 227, + 59: 253, + 60: 8, + 61: 8, + 62: 233, + 63: 17, + 64: 192, + 65: 8, + 66: 195, + 67: 232, + 68: 233, + 69: 17, + 70: 193, + 71: 232, + 72: 232, + 73: 232, + 74: 8, + 75: 0, + 76: 194, + 77: 0, + 78: 0, + 79: 0, + 80: 0, + 81: 0, + 82: 8, + 83: 0, + 84: 0, + 85: 0, + 86: 0, + 87: 0, + 88: 14, + 89: 14, + 90: 14, + 91: 189, + 92: 8, + 93: 8, + 94: 222, + 95: 8, + 96: 8, + 97: 232, + 98: 233, + 99: 17, + 100: 228, + 101: 15, + 102: 232, + 103: 233, + 104: 17, + 105: 18, + 106: 229, + 107: 232, + 108: 8, + 109: 8, + 110: 0, + 111: 54, + 112: 15, + 113: 0, + 114: 2, + 115: 0, + 116: 0, + 117: 0, + 118: 8, + 119: 0, + 120: 2, + 121: 23, + 122: 23, + 123: 23, + 124: 252, + 125: 252, + 126: 189, + 127: 189, + 128: 8, + 129: 8, + 130: 223, + 131: 232, + 132: 232, + 133: 232, + 134: 233, + 135: 17, + 136: 229, + 137: 232, + 138: 233, + 139: 8, + 140: 53, + 141: 18, + 142: 229, + 143: 232, + 144: 8, + 145: 0, + 146: 17, + 147: 19, + 148: 15, + 149: 0, + 150: 0, + 151: 2, + 152: 23, + 153: 24, + 154: 8, + 155: 0, + 156: 2, + 157: 2, + 158: 29, + 159: 6, + 160: 8, + 161: 8, + 162: 8, + 163: 8, + 164: 8, + 165: 8, + 166: 8, + 167: 233, + 168: 233, + 169: 8, + 170: 8, + 171: 0, + 172: 15, + 173: 8, + 174: 1, + 175: 0, + 176: 53, + 177: 53, + 178: 15, + 179: 0, + 180: 0, + 181: 1, + 182: 53, + 183: 55, + 184: 15, + 185: 0, + 186: 0, + 187: 58, + 188: 10, + 189: 4, + 190: 8, + 191: 0, + 192: 58, + 193: 2, + 194: 35, + 195: 66, + 196: 8, + 197: 8, + 198: 8, + 199: 8, + 200: 8, + 201: 8, + 202: 8, + 203: 0, + 204: 0, + 205: 0, + 206: 0, + 207: 53, + 208: 8, + 209: 0, + 210: 1, + 211: 0, + 212: 53, + 213: 53, + 214: 8, + 215: 0, + 216: 0, + 217: 1, + 218: 89, + 219: 5, + 220: 8, + 221: 0, + 222: 58, + 223: 95, + 224: 131, + 225: 126, + 226: 8, + 227: 0, + 228: 58, + 229: 3, + 230: 143, + 231: 242, + 232: 14, + 233: 14, + 234: 14, + 235: 14, + 236: 14, + 237: 14, + 238: 251, + 239: 252, + 240: 188, + 241: 8, + 242: 8, + 243: 8, + 244: 8, + 245: 232, + 246: 233, + 247: 8, + 248: 0, + 249: 0, + 250: 0, + 251: 0, + 252: 239, + 253: 10, + 254: 242, + 255: 243, + }, + }, + "solarized-light16": { + Reset: 0, + DefaultFg: 15, + DefaultBg: 4, + UsernameFg: 15, + UsernameBg: 4, + UsernameRootBg: 1, + HostnameFg: 15, + HostnameBg: 7, + HomeSpecialDisplay: false, + HomeFg: 15, + HomeBg: 4, + PathFg: 15, + PathBg: 10, + CwdFg: 15, + SeparatorFg: 15, + ReadonlyFg: 8, + ReadonlyBg: 1, + SSHFg: 8, + SSHBg: 9, + DockerMachineFg: 13, + DockerMachineBg: 55, + DotEnvFg: 15, + DotEnvBg: 55, + RepoCleanFg: 15, + RepoCleanBg: 3, + RepoDirtyFg: 15, + RepoDirtyBg: 5, + JobsFg: 4, + JobsBg: 0, + CmdPassedFg: 10, + CmdPassedBg: 7, + CmdFailedFg: 15, + CmdFailedBg: 5, + SvnChangesFg: 2, + SvnChangesBg: 3, + GitAheadFg: 14, + GitAheadBg: 10, + GitBehindFg: 14, + GitBehindBg: 10, + GitStagedFg: 15, + GitStagedBg: 2, + GitNotStagedFg: 15, + GitNotStagedBg: 9, + GitUntrackedFg: 15, + GitUntrackedBg: 1, + GitConflictedFg: 15, + GitConflictedBg: 1, + GitStashedFg: 15, + GitStashedBg: 4, + GoenvBg: 38, // approx. Gopher Blue + GoenvFg: 220, // approx. Secondary Yellow + VirtualEnvFg: 8, + VirtualEnvBg: 6, + PerlbrewFg: 8, + PerlbrewBg: 4, + PlEnvFg: 8, + PlEnvBg: 4, + TimeFg: 15, + TimeBg: 0, + ShellVarFg: 1, + ShellVarBg: 11, + ShEnvFg: 15, + ShEnvBg: 9, + NodeFg: 15, + NodeBg: 40, + LoadFg: 15, + LoadBg: 2, + LoadHighBg: 5, + LoadAvgValue: 5, + LoadThresholdBad: 1.0, + NixShellFg: 0, + NixShellBg: 7, + HostnameColorizedFgMap: map[uint8]uint8{ + 0: 14, + 1: 14, + 2: 120, + 3: 228, + 4: 14, + 5: 14, + 6: 123, + 7: 0, + 8: 8, + 9: 8, + 10: 8, + 11: 8, + 12: 14, + 13: 8, + 14: 8, + 15: 242, + 16: 14, + 17: 14, + 18: 14, + 19: 189, + 20: 8, + 21: 14, + 22: 83, + 23: 87, + 24: 117, + 25: 188, + 26: 8, + 27: 8, + 28: 120, + 29: 122, + 30: 123, + 31: 159, + 32: 8, + 33: 8, + 34: 157, + 35: 158, + 36: 159, + 37: 159, + 38: 195, + 39: 8, + 40: 194, + 41: 194, + 42: 195, + 43: 195, + 44: 195, + 45: 8, + 46: 8, + 47: 8, + 48: 8, + 49: 8, + 50: 8, + 51: 8, + 52: 14, + 53: 14, + 54: 14, + 55: 189, + 56: 8, + 57: 14, + 58: 227, + 59: 253, + 60: 8, + 61: 8, + 62: 233, + 63: 17, + 64: 192, + 65: 8, + 66: 195, + 67: 232, + 68: 233, + 69: 17, + 70: 193, + 71: 232, + 72: 232, + 73: 232, + 74: 8, + 75: 0, + 76: 194, + 77: 0, + 78: 0, + 79: 0, + 80: 0, + 81: 0, + 82: 8, + 83: 0, + 84: 0, + 85: 0, + 86: 0, + 87: 0, + 88: 14, + 89: 14, + 90: 14, + 91: 189, + 92: 8, + 93: 8, + 94: 222, + 95: 8, + 96: 8, + 97: 232, + 98: 233, + 99: 17, + 100: 228, + 101: 15, + 102: 232, + 103: 233, + 104: 17, + 105: 18, + 106: 229, + 107: 232, + 108: 8, + 109: 8, + 110: 0, + 111: 54, + 112: 15, + 113: 0, + 114: 2, + 115: 0, + 116: 0, + 117: 0, + 118: 8, + 119: 0, + 120: 2, + 121: 23, + 122: 23, + 123: 23, + 124: 252, + 125: 252, + 126: 189, + 127: 189, + 128: 8, + 129: 8, + 130: 223, + 131: 232, + 132: 232, + 133: 232, + 134: 233, + 135: 17, + 136: 229, + 137: 232, + 138: 233, + 139: 8, + 140: 53, + 141: 18, + 142: 229, + 143: 232, + 144: 8, + 145: 0, + 146: 17, + 147: 19, + 148: 15, + 149: 0, + 150: 0, + 151: 2, + 152: 23, + 153: 24, + 154: 8, + 155: 0, + 156: 2, + 157: 2, + 158: 29, + 159: 6, + 160: 8, + 161: 8, + 162: 8, + 163: 8, + 164: 8, + 165: 8, + 166: 8, + 167: 233, + 168: 233, + 169: 8, + 170: 8, + 171: 0, + 172: 15, + 173: 8, + 174: 1, + 175: 0, + 176: 53, + 177: 53, + 178: 15, + 179: 0, + 180: 0, + 181: 1, + 182: 53, + 183: 55, + 184: 15, + 185: 0, + 186: 0, + 187: 58, + 188: 10, + 189: 4, + 190: 8, + 191: 0, + 192: 58, + 193: 2, + 194: 35, + 195: 66, + 196: 8, + 197: 8, + 198: 8, + 199: 8, + 200: 8, + 201: 8, + 202: 8, + 203: 0, + 204: 0, + 205: 0, + 206: 0, + 207: 53, + 208: 8, + 209: 0, + 210: 1, + 211: 0, + 212: 53, + 213: 53, + 214: 8, + 215: 0, + 216: 0, + 217: 1, + 218: 89, + 219: 5, + 220: 8, + 221: 0, + 222: 58, + 223: 95, + 224: 131, + 225: 126, + 226: 8, + 227: 0, + 228: 58, + 229: 3, + 230: 143, + 231: 242, + 232: 14, + 233: 14, + 234: 14, + 235: 14, + 236: 14, + 237: 14, + 238: 251, + 239: 252, + 240: 188, + 241: 8, + 242: 8, + 243: 8, + 244: 8, + 245: 232, + 246: 233, + 247: 8, + 248: 0, + 249: 0, + 250: 0, + 251: 0, + 252: 239, + 253: 10, + 254: 242, + 255: 243, + }, + }, + "gruvbox": { + /* based on https://github.com/b-ryan/powerline-shell/blob/master/powerline_shell/themes/gruvbox.py */ + Reset: 0, + DefaultFg: gruvbox_light0, + DefaultBg: gruvbox_dark0, + UsernameFg: gruvbox_bright_purple, + UsernameBg: gruvbox_dark2, + UsernameRootBg: gruvbox_faded_red, + HostnameFg: gruvbox_bright_purple, + HostnameBg: gruvbox_dark1, + HomeSpecialDisplay: true, + HomeFg: gruvbox_light2, + HomeBg: gruvbox_neutral_blue, + PathFg: gruvbox_light3, + PathBg: gruvbox_dark3, + CwdFg: gruvbox_light2, + SeparatorFg: gruvbox_dark_gray, + ReadonlyFg: gruvbox_light0, + ReadonlyBg: gruvbox_bright_red, + SSHFg: gruvbox_light0, + SSHBg: gruvbox_faded_purple, + DockerMachineFg: gruvbox_light0, // match ssh-fg + DockerMachineBg: gruvbox_faded_purple, // match ssh-bg + DotEnvFg: gruvbox_light0, // match ssh-fg + DotEnvBg: gruvbox_faded_purple, // match ssh-bg + RepoCleanFg: gruvbox_dark1, + RepoCleanBg: gruvbox_faded_green, + RepoDirtyFg: gruvbox_light0, + RepoDirtyBg: gruvbox_faded_orange, + JobsFg: gruvbox_neutral_aqua, + JobsBg: gruvbox_dark1, + CmdPassedFg: gruvbox_light4, + CmdPassedBg: gruvbox_dark1, + CmdFailedFg: gruvbox_light0, + CmdFailedBg: gruvbox_neutral_red, + SvnChangesFg: gruvbox_light0, + SvnChangesBg: gruvbox_faded_orange, + GitAheadFg: gruvbox_light3, + GitAheadBg: gruvbox_dark2, + GitBehindFg: gruvbox_light3, + GitBehindBg: gruvbox_dark2, + GitStagedFg: gruvbox_light0, + GitStagedBg: gruvbox_neutral_green, + GitNotStagedFg: gruvbox_light0, + GitNotStagedBg: gruvbox_neutral_orange, + GitUntrackedFg: gruvbox_light0, + GitUntrackedBg: gruvbox_faded_red, + GitConflictedFg: gruvbox_light0, + GitConflictedBg: gruvbox_neutral_red, + GitStashedFg: gruvbox_dark0, + GitStashedBg: gruvbox_neutral_yellow, + GoenvBg: gruvbox_faded_blue, + GoenvFg: gruvbox_light1, + VirtualEnvFg: gruvbox_light0, + VirtualEnvBg: gruvbox_faded_green, + PerlbrewFg: gruvbox_light0, // match virtualenv + PerlbrewBg: gruvbox_faded_green, // match virtualenv + PlEnvFg: gruvbox_light0, // match virtualenv + PlEnvBg: gruvbox_faded_green, // match virtualenv + TimeFg: gruvbox_light2, + TimeBg: gruvbox_dark4, + ShellVarFg: gruvbox_light0, // match ssh-fg + ShellVarBg: gruvbox_faded_purple, // match ssh-bg + NodeFg: gruvbox_light0, // match virtualenv + NodeBg: gruvbox_faded_green, // match virtualenv + LoadFg: gruvbox_light0, + LoadBg: gruvbox_faded_purple, + LoadHighBg: gruvbox_neutral_red, + LoadAvgValue: gruvbox_light0, + LoadThresholdBad: 1.0, + NixShellFg: gruvbox_light0, + NixShellBg: gruvbox_faded_purple, }, - }, - "gruvbox": { - /* based on https://github.com/b-ryan/powerline-shell/blob/master/powerline_shell/themes/gruvbox.py */ - Reset: 0, - DefaultFg: gruvbox_light0, - DefaultBg: gruvbox_dark0, - UsernameFg: gruvbox_bright_purple, - UsernameBg: gruvbox_dark2, - UsernameRootBg: gruvbox_faded_red, - HostnameFg: gruvbox_bright_purple, - HostnameBg: gruvbox_dark1, - HomeSpecialDisplay: true, - HomeFg: gruvbox_light2, - HomeBg: gruvbox_neutral_blue, - PathFg: gruvbox_light3, - PathBg: gruvbox_dark3, - CwdFg: gruvbox_light2, - SeparatorFg: gruvbox_dark_gray, - ReadonlyFg: gruvbox_light0, - ReadonlyBg: gruvbox_bright_red, - SSHFg: gruvbox_light0, - SSHBg: gruvbox_faded_purple, - DockerMachineFg: gruvbox_light0, // match ssh-fg - DockerMachineBg: gruvbox_faded_purple, // match ssh-bg - DotEnvFg: gruvbox_light0, // match ssh-fg - DotEnvBg: gruvbox_faded_purple, // match ssh-bg - RepoCleanFg: gruvbox_dark1, - RepoCleanBg: gruvbox_faded_green, - RepoDirtyFg: gruvbox_light0, - RepoDirtyBg: gruvbox_faded_orange, - JobsFg: gruvbox_neutral_aqua, - JobsBg: gruvbox_dark1, - CmdPassedFg: gruvbox_light4, - CmdPassedBg: gruvbox_dark1, - CmdFailedFg: gruvbox_light0, - CmdFailedBg: gruvbox_neutral_red, - SvnChangesFg: gruvbox_light0, - SvnChangesBg: gruvbox_faded_orange, - GitAheadFg: gruvbox_light3, - GitAheadBg: gruvbox_dark2, - GitBehindFg: gruvbox_light3, - GitBehindBg: gruvbox_dark2, - GitStagedFg: gruvbox_light0, - GitStagedBg: gruvbox_neutral_green, - GitNotStagedFg: gruvbox_light0, - GitNotStagedBg: gruvbox_neutral_orange, - GitUntrackedFg: gruvbox_light0, - GitUntrackedBg: gruvbox_faded_red, - GitConflictedFg: gruvbox_light0, - GitConflictedBg: gruvbox_neutral_red, - GitStashedFg: gruvbox_dark0, - GitStashedBg: gruvbox_neutral_yellow, - GoenvBg: gruvbox_faded_blue, - GoenvFg: gruvbox_light1, - VirtualEnvFg: gruvbox_light0, - VirtualEnvBg: gruvbox_faded_green, - PerlbrewFg: gruvbox_light0, // match virtualenv - PerlbrewBg: gruvbox_faded_green, // match virtualenv - PlEnvFg: gruvbox_light0, // match virtualenv - PlEnvBg: gruvbox_faded_green, // match virtualenv - TimeFg: gruvbox_light2, - TimeBg: gruvbox_dark4, - ShellVarFg: gruvbox_light0, // match ssh-fg - ShellVarBg: gruvbox_faded_purple, // match ssh-bg - NodeFg: gruvbox_light0, // match virtualenv - NodeBg: gruvbox_faded_green, // match virtualenv - LoadFg: gruvbox_light0, - LoadBg: gruvbox_faded_purple, - LoadHighBg: gruvbox_neutral_red, - LoadAvgValue: gruvbox_light0, - LoadThresholdBad: 1.0, - NixShellFg: gruvbox_light0, - NixShellBg: gruvbox_faded_purple, }, } diff --git a/main.go b/main.go index 154de100..9f950619 100644 --- a/main.go +++ b/main.go @@ -149,44 +149,44 @@ func main() { args := args{ CwdMode: flag.String( "cwd-mode", - "fancy", + defaults.CwdMode, commentsWithDefaults("How to display the current directory", "(valid choices: fancy, semifancy, plain, dironly)")), CwdMaxDepth: flag.Int( "cwd-max-depth", - 5, + defaults.CwdMaxDepth, commentsWithDefaults("Maximum number of directories to show in path")), CwdMaxDirSize: flag.Int( "cwd-max-dir-size", - -1, + defaults.CwdMaxDirSize, commentsWithDefaults("Maximum number of letters displayed for each directory in the path")), ColorizeHostname: flag.Bool( "colorize-hostname", - false, + defaults.ColorizeHostname, comments("Colorize the hostname based on a hash of itself, or use the PLGO_HOSTNAMEFG and/or PLGO_HOSTNAMEBG env vars.")), HostnameOnlyIfSSH: flag.Bool( "hostname-only-if-ssh", - false, + defaults.HostnameOnlyIfSSH, comments("Show hostname only for SSH connections")), SshAlternateIcon: flag.Bool( "alternate-ssh-icon", - false, + defaults.SshAlternateIcon, comments("Show the older, original icon for SSH connections")), EastAsianWidth: flag.Bool( "east-asian-width", - false, + defaults.EastAsianWidth, comments("Use East Asian Ambiguous Widths")), PromptOnNewLine: flag.Bool( "newline", - false, + defaults.PromptOnNewLine, comments("Show the prompt on a new line")), StaticPromptIndicator: flag.Bool( "static-prompt-indicator", - false, + defaults.StaticPromptIndicator, comments("Always show the prompt indicator with the default color, never with the error color")), VenvNameSizeLimit: flag.Int( "venv-name-size-limit", - 0, + defaults.VenvNameSizeLimit, comments("Show indicator instead of virtualenv name if name is longer than this limit (defaults to 0, which is unlimited)")), Jobs: flag.Int( "jobs", @@ -194,88 +194,88 @@ func main() { comments("Number of jobs currently running")), GitAssumeUnchangedSize: flag.Int64( "git-assume-unchanged-size", - 2048, + defaults.GitAssumeUnchangedSize, comments("Disable checking for changed/edited files in git repositories where the index is larger than this size (in KB), improves performance")), GitDisableStats: flag.String( "git-disable-stats", - "", + strings.Join(defaults.GitDisableStats, ","), commentsWithDefaults("Comma-separated list to disable individual git statuses", "(valid choices: ahead, behind, staged, notStaged, untracked, conflicted, stashed)")), GitMode: flag.String( "git-mode", - "fancy", + defaults.GitMode, commentsWithDefaults("How to display git status", "(valid choices: fancy, simple)")), Mode: flag.String( "mode", - "patched", + defaults.Mode, commentsWithDefaults("The characters used to make separators between segments.", "(valid choices: patched, compatible, flat)")), Theme: flag.String( "theme", - "default", + defaults.Theme, commentsWithDefaults("Set this to the theme you want to use", "(valid choices: default, low-contrast)")), Shell: flag.String( "shell", - "autodetect", + defaults.Shell, commentsWithDefaults("Set this to your shell type", "(valid choices: autodetect, bare, bash, zsh)")), Modules: flag.String( "modules", - "venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root", + strings.Join(defaults.Modules, ","), commentsWithDefaults("The list of modules to load, separated by ','", "(valid choices: aws, cwd, docker, docker-context, dotenv, duration, exit, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)")), ModulesRight: flag.String( "modules-right", - "", + strings.Join(defaults.ModulesRight, ","), comments("The list of modules to load anchored to the right, for shells that support it, separated by ','", "(valid choices: aws, cwd, docker, docker-context, dotenv, duration, exit, git, gitlite, goenv, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)")), Priority: flag.String( "priority", - "root,cwd,user,host,ssh,perms,git-branch,git-status,hg,jobs,exit,cwd-path", + strings.Join(defaults.Priority, ","), commentsWithDefaults("Segments sorted by priority, if not enough space exists, the least priorized segments are removed first. Separate with ','", "(valid choices: aws, cwd, docker, docker-context, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, plenv, root, shell-var, shenv, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo)")), MaxWidthPercentage: flag.Int( "max-width", - 0, + defaults.MaxWidthPercentage, comments("Maximum width of the shell that the prompt may use, in percent. Setting this to 0 disables the shrinking subsystem.")), TruncateSegmentWidth: flag.Int( "truncate-segment-width", - 16, + defaults.TruncateSegmentWidth, commentsWithDefaults("Maximum width of a segment, segments longer than this will be shortened if space is limited. Setting this to 0 disables it.")), PrevError: flag.Int( "error", - 0, + defaults.PrevError, comments("Exit code of previously executed command")), NumericExitCodes: flag.Bool( "numeric-exit-codes", - false, + defaults.NumericExitCodes, comments("Shows numeric exit codes for errors.")), IgnoreRepos: flag.String( "ignore-repos", - "", + strings.Join(defaults.IgnoreRepos, ","), comments("A list of git repos to ignore. Separate with ','.", "Repos are identified by their root directory.")), ShortenGKENames: flag.Bool( "shorten-gke-names", - false, + defaults.ShortenGKENames, comments("Shortens names for GKE Kube clusters.")), ShortenEKSNames: flag.Bool( "shorten-eks-names", - false, + defaults.ShortenEKSNames, comments("Shortens names for EKS Kube clusters.")), ShellVar: flag.String( "shell-var", - "", + defaults.ShellVar, comments("A shell variable to add to the segments.")), ShellVarNoWarnEmpty: flag.Bool( "shell-var-no-warn-empty", - false, + defaults.ShellVarNoWarnEmpty, comments("Disables warning for empty shell variable.")), TrimADDomain: flag.Bool( "trim-ad-domain", - false, + defaults.TrimADDomain, comments("Trim the Domainname from the AD username.")), PathAliases: flag.String( "path-aliases", @@ -286,58 +286,136 @@ func main() { "Use '~' for your home dir. You may need to escape this character to avoid shell substitution.")), Duration: flag.String( "duration", - "", + defaults.Duration, comments("The elapsed clock-time of the previous command")), DurationMin: flag.String( "duration-min", - "0", + defaults.DurationMin, comments("The minimal time a command has to take before the duration segment is shown")), Eval: flag.Bool( "eval", - false, + defaults.Eval, comments("Output prompt in 'eval' format.")), Condensed: flag.Bool( "condensed", - false, + defaults.Condensed, comments("Remove spacing between segments")), } flag.Parse() - if strings.HasSuffix(*args.Theme, ".json") { - jsonTheme := themes["default"] - file, err := ioutil.ReadFile(*args.Theme) + cfg := defaults + err := cfg.Load() + if err != nil { + println("Error loading config") + println(err.Error()) + } + + flag.Visit(func(f *flag.Flag) { + switch f.Name { + case "cwd-mode": + cfg.CwdMode = *args.CwdMode + case "cwd-max-depth": + cfg.CwdMaxDepth = *args.CwdMaxDepth + case "cwd-max-dir-size": + cfg.CwdMaxDirSize = *args.CwdMaxDirSize + case "colorize-hostname": + cfg.ColorizeHostname = *args.ColorizeHostname + case "hostname-only-if-ssh": + cfg.HostnameOnlyIfSSH = *args.HostnameOnlyIfSSH + case "alternate-ssh-icon": + cfg.SshAlternateIcon = *args.SshAlternateIcon + case "east-asian-width": + cfg.EastAsianWidth = *args.EastAsianWidth + case "newline": + cfg.PromptOnNewLine = *args.PromptOnNewLine + case "static-prompt-indicator": + cfg.StaticPromptIndicator = *args.StaticPromptIndicator + case "venv-name-size-limit": + cfg.VenvNameSizeLimit = *args.VenvNameSizeLimit + case "git-assume-unchanged-size": + cfg.GitAssumeUnchangedSize = *args.GitAssumeUnchangedSize + case "git-disable-stats": + cfg.GitDisableStats = strings.Split(*args.GitDisableStats, ",") + case "git-mode": + cfg.GitMode = *args.GitMode + case "mode": + cfg.Mode = *args.Mode + case "theme": + cfg.Theme = *args.Theme + case "shell": + cfg.Shell = *args.Shell + case "modules": + cfg.Modules = strings.Split(*args.Modules, ",") + case "modules-right": + cfg.ModulesRight = strings.Split(*args.ModulesRight, ",") + case "priority": + cfg.Priority = strings.Split(*args.Priority, ",") + case "max-width-percentage": + cfg.MaxWidthPercentage = *args.MaxWidthPercentage + case "truncate-segment-width": + cfg.TruncateSegmentWidth = *args.TruncateSegmentWidth + case "error": + cfg.PrevError = *args.PrevError + case "numeric-exit-codes": + cfg.NumericExitCodes = *args.NumericExitCodes + case "ignore-repos": + cfg.IgnoreRepos = strings.Split(*args.IgnoreRepos, ",") + case "shorten-gke-names": + cfg.ShortenGKENames = *args.ShortenGKENames + case "shorten-eks-names": + cfg.ShortenEKSNames = *args.ShortenEKSNames + case "shell-var": + cfg.ShellVar = *args.ShellVar + case "shell-var-no-warn-empty": + cfg.ShellVarNoWarnEmpty = *args.ShellVarNoWarnEmpty + case "trim-ad-domain": + cfg.TrimADDomain = *args.TrimADDomain + case "path-aliases": + for _, pair := range strings.Split(*args.PathAliases, ",") { + kv := strings.SplitN(pair, "=", 2) + cfg.PathAliases[kv[0]] = kv[1] + } + case "duration": + cfg.Duration = *args.Duration + case "duration-min": + cfg.DurationMin = *args.DurationMin + case "eval": + cfg.Eval = *args.Eval + case "condensed": + cfg.Condensed = *args.Condensed + } + }) + + if strings.HasSuffix(cfg.Theme, ".json") { + file, err := ioutil.ReadFile(cfg.Theme) if err == nil { - err = json.Unmarshal(file, &jsonTheme) + theme := cfg.Themes[defaults.Theme] + err = json.Unmarshal(file, &theme) if err == nil { - themes[*args.Theme] = jsonTheme + cfg.Themes[cfg.Theme] = theme } else { println("Error reading theme") println(err.Error()) } } } - if strings.HasSuffix(*args.Mode, ".json") { - modeTheme := symbolTemplates["compatible"] - file, err := ioutil.ReadFile(*args.Mode) + if strings.HasSuffix(cfg.Mode, ".json") { + file, err := ioutil.ReadFile(cfg.Mode) if err == nil { - err = json.Unmarshal(file, &modeTheme) + symbols := cfg.Modes[defaults.Mode] + err = json.Unmarshal(file, &symbols) if err == nil { - symbolTemplates[*args.Mode] = modeTheme + cfg.Modes[cfg.Mode] = symbols } else { println("Error reading mode") println(err.Error()) } } } - priorities := map[string]int{} - priorityList := strings.Split(*args.Priority, ",") - for idx, priority := range priorityList { - priorities[priority] = len(priorityList) - idx - } - p := newPowerline(args, getValidCwd(), priorities, alignLeft) - if p.supportsRightModules() && p.hasRightModules() && !*args.Eval { + p := newPowerline(cfg, getValidCwd(), alignLeft) + if p.supportsRightModules() && p.hasRightModules() && !cfg.Eval { panic("Flag '-modules-right' requires '-eval' mode.") } diff --git a/powerline.go b/powerline.go index 8a80d56c..c067736e 100644 --- a/powerline.go +++ b/powerline.go @@ -18,30 +18,28 @@ import ( // ShellInfo holds the shell information type ShellInfo struct { - rootIndicator string - colorTemplate string - escapedDollar string - escapedBacktick string - escapedBackslash string - evalPromptPrefix string - evalPromptSuffix string - evalPromptRightPrefix string - evalPromptRightSuffix string + RootIndicator string + ColorTemplate string + EscapedDollar string + EscapedBacktick string + EscapedBackslash string + EvalPromptPrefix string + EvalPromptSuffix string + EvalPromptRightPrefix string + EvalPromptRightSuffix string } type powerline struct { - args args + cfg Config cwd string userInfo user.User userIsAdmin bool hostname string username string - pathAliases map[string]string theme Theme - shell string - shellInfo ShellInfo + shell ShellInfo reset string - symbolTemplates Symbols + symbols SymbolTemplate priorities map[string]int ignoreRepos map[string]bool Segments [][]pwl.Segment @@ -56,9 +54,9 @@ type prioritizedSegments struct { segs []pwl.Segment } -func newPowerline(args args, cwd string, priorities map[string]int, align alignment) *powerline { +func newPowerline(cfg Config, cwd string, align alignment) *powerline { p := new(powerline) - p.args = args + p.cfg = cfg p.cwd = cwd userInfo, err := user.Current() if userInfo != nil && err == nil { @@ -72,7 +70,7 @@ func newPowerline(args args, cwd string, priorities map[string]int, align alignm } else { p.username = p.userInfo.Username } - if args.TrimADDomain != nil && *args.TrimADDomain { + if cfg.TrimADDomain { usernameWithAd := strings.SplitN(p.username, `\`, 2) if len(usernameWithAd) > 1 { // remove the Domain name from username @@ -81,47 +79,40 @@ func newPowerline(args args, cwd string, priorities map[string]int, align alignm } p.userIsAdmin = userIsAdmin() - p.theme = themes[*args.Theme] - if *args.Shell == "autodetect" { - p.shell = detectShell(os.Getenv("SHELL")) - } else { - p.shell = *args.Shell + p.theme = cfg.Themes[cfg.Theme] + if cfg.Shell == "autodetect" { + cfg.Shell = detectShell(os.Getenv("SHELL")) + } + p.shell = cfg.Shells[cfg.Shell] + p.reset = fmt.Sprintf(p.shell.ColorTemplate, "[0m") + p.symbols = cfg.Modes[cfg.Mode] + p.priorities = make(map[string]int) + for idx, priority := range cfg.Priority { + p.priorities[priority] = len(cfg.Priority) - idx } - p.shellInfo = shellInfos[p.shell] - p.reset = fmt.Sprintf(p.shellInfo.colorTemplate, "[0m") - p.symbolTemplates = symbolTemplates[*args.Mode] - p.priorities = priorities p.align = align p.ignoreRepos = make(map[string]bool) - for _, r := range strings.Split(*args.IgnoreRepos, ",") { + for _, r := range cfg.IgnoreRepos { if r == "" { continue } p.ignoreRepos[r] = true } - p.pathAliases = make(map[string]string) - for _, pa := range strings.Split(*args.PathAliases, ",") { - if pa == "" { - continue - } - kv := strings.SplitN(pa, "=", 2) - p.pathAliases[kv[0]] = kv[1] - } p.Segments = make([][]pwl.Segment, 1) - var mods string + var mods []string if p.align == alignLeft { - mods = *args.Modules - if len(*args.ModulesRight) > 0 { + mods = cfg.Modules + if len(cfg.ModulesRight) > 0 { if p.supportsRightModules() { - p.rightPowerline = newPowerline(args, cwd, priorities, alignRight) + p.rightPowerline = newPowerline(cfg, cwd, alignRight) } else { - mods += `,` + *args.ModulesRight + mods = append(mods, cfg.ModulesRight...) } } } else { - mods = *args.ModulesRight + mods = cfg.ModulesRight } - initSegments(p, strings.Split(mods, ",")) + initSegments(p, mods) return p } @@ -182,7 +173,7 @@ func (p *powerline) color(prefix string, code uint8) string { if code == p.theme.Reset { return p.reset } - return fmt.Sprintf(p.shellInfo.colorTemplate, fmt.Sprintf("[%s;5;%dm", prefix, code)) + return fmt.Sprintf(p.shell.ColorTemplate, fmt.Sprintf("[%s;5;%dm", prefix, code)) } func (p *powerline) fgColor(code uint8) string { @@ -200,9 +191,9 @@ func (p *powerline) appendSegment(origin string, segment pwl.Segment) { } if segment.Separator == "" { if p.isRightPrompt() { - segment.Separator = p.symbolTemplates.SeparatorReverse + segment.Separator = p.symbols.SeparatorReverse } else { - segment.Separator = p.symbolTemplates.Separator + segment.Separator = p.symbols.Separator } } if segment.SeparatorForeground == 0 { @@ -210,7 +201,7 @@ func (p *powerline) appendSegment(origin string, segment pwl.Segment) { } priority, _ := p.priorities[origin] segment.Priority += priority - segment.Width = segment.ComputeWidth(*p.args.Condensed) + segment.Width = segment.ComputeWidth(p.cfg.Condensed) if segment.NewLine { p.newRow() } else { @@ -246,7 +237,7 @@ func termWidth() int { func (p *powerline) truncateRow(rowNum int) { - shellMaxLength := termWidth() * *p.args.MaxWidthPercentage / 100 + shellMaxLength := termWidth() * p.cfg.MaxWidthPercentage / 100 row := p.Segments[rowNum] rowLength := 0 @@ -255,11 +246,11 @@ func (p *powerline) truncateRow(rowNum int) { rowLength += segment.Width } - if rowLength > shellMaxLength && *p.args.TruncateSegmentWidth > 0 { + if rowLength > shellMaxLength && p.cfg.TruncateSegmentWidth > 0 { minPriorityNotTruncated := MaxInteger minPriorityNotTruncatedSegmentID := -1 for idx, segment := range row { - if segment.Width > *p.args.TruncateSegmentWidth && segment.Priority < minPriorityNotTruncated { + if segment.Width > p.cfg.TruncateSegmentWidth && segment.Priority < minPriorityNotTruncated { minPriorityNotTruncated = segment.Priority minPriorityNotTruncatedSegmentID = idx } @@ -269,8 +260,8 @@ func (p *powerline) truncateRow(rowNum int) { rowLength -= segment.Width - segment.Content = runewidth.Truncate(segment.Content, *p.args.TruncateSegmentWidth-runewidth.StringWidth(segment.Separator)-3, "…") - segment.Width = segment.ComputeWidth(*p.args.Condensed) + segment.Content = runewidth.Truncate(segment.Content, p.cfg.TruncateSegmentWidth-runewidth.StringWidth(segment.Separator)-3, "…") + segment.Width = segment.ComputeWidth(p.cfg.Condensed) row = append(append(row[:minPriorityNotTruncatedSegmentID], segment), row[minPriorityNotTruncatedSegmentID+1:]...) rowLength += segment.Width @@ -278,7 +269,7 @@ func (p *powerline) truncateRow(rowNum int) { minPriorityNotTruncated = MaxInteger minPriorityNotTruncatedSegmentID = -1 for idx, segment := range row { - if segment.Width > *p.args.TruncateSegmentWidth && segment.Priority < minPriorityNotTruncated { + if segment.Width > p.cfg.TruncateSegmentWidth && segment.Priority < minPriorityNotTruncated { minPriorityNotTruncated = segment.Priority minPriorityNotTruncatedSegmentID = idx } @@ -306,7 +297,7 @@ func (p *powerline) truncateRow(rowNum int) { } func (p *powerline) numEastAsianRunes(segmentContent *string) int { - if !*p.args.EastAsianWidth { + if !p.cfg.EastAsianWidth { return 0 } numEastAsianRunes := 0 @@ -363,12 +354,12 @@ func (p *powerline) drawRow(rowNum int, buffer *bytes.Buffer) { } buffer.WriteString(p.fgColor(segment.Foreground)) buffer.WriteString(p.bgColor(segment.Background)) - if !*p.args.Condensed { + if !p.cfg.Condensed { buffer.WriteRune(' ') } buffer.WriteString(segment.Content) numEastAsianRunes += p.numEastAsianRunes(&segment.Content) - if !*p.args.Condensed { + if !p.cfg.Condensed { buffer.WriteRune(' ') } if !p.isRightPrompt() { @@ -396,11 +387,11 @@ func (p *powerline) draw() string { var buffer bytes.Buffer - if *p.args.Eval { + if p.cfg.Eval { if p.align == alignLeft { - buffer.WriteString(p.shellInfo.evalPromptPrefix) + buffer.WriteString(p.shell.EvalPromptPrefix) } else if p.supportsRightModules() { - buffer.WriteString(p.shellInfo.evalPromptRightPrefix) + buffer.WriteString(p.shell.EvalPromptRightPrefix) } } @@ -412,11 +403,11 @@ func (p *powerline) draw() string { } } - if *p.args.PromptOnNewLine { + if p.cfg.PromptOnNewLine { buffer.WriteRune('\n') var foreground, background uint8 - if *p.args.PrevError == 0 || *p.args.StaticPromptIndicator { + if p.cfg.PrevError == 0 || p.cfg.StaticPromptIndicator { foreground = p.theme.CmdPassedFg background = p.theme.CmdPassedBg } else { @@ -426,28 +417,28 @@ func (p *powerline) draw() string { buffer.WriteString(p.fgColor(foreground)) buffer.WriteString(p.bgColor(background)) - buffer.WriteString(p.shellInfo.rootIndicator) + buffer.WriteString(p.shell.RootIndicator) buffer.WriteString(p.reset) buffer.WriteString(p.fgColor(background)) - buffer.WriteString(p.symbolTemplates.Separator) + buffer.WriteString(p.symbols.Separator) buffer.WriteString(p.reset) buffer.WriteRune(' ') } - if *p.args.Eval { + if p.cfg.Eval { switch p.align { case alignLeft: - buffer.WriteString(p.shellInfo.evalPromptSuffix) + buffer.WriteString(p.shell.EvalPromptSuffix) if p.supportsRightModules() { buffer.WriteRune('\n') if !p.hasRightModules() { - buffer.WriteString(p.shellInfo.evalPromptRightPrefix + p.shellInfo.evalPromptRightSuffix) + buffer.WriteString(p.shell.EvalPromptRightPrefix + p.shell.EvalPromptRightSuffix) } } case alignRight: if p.supportsRightModules() { buffer.Truncate(buffer.Len() - 1) - buffer.WriteString(p.shellInfo.evalPromptRightSuffix) + buffer.WriteString(p.shell.EvalPromptRightSuffix) } } if p.hasRightModules() { @@ -463,9 +454,10 @@ func (p *powerline) hasRightModules() bool { } func (p *powerline) supportsRightModules() bool { - return p.shellInfo.evalPromptRightPrefix != "" || p.shellInfo.evalPromptRightSuffix != "" + return p.shell.EvalPromptRightPrefix != "" || p.shell.EvalPromptRightSuffix != "" } func (p *powerline) isRightPrompt() bool { return p.align == alignRight && p.supportsRightModules() } + diff --git a/segment-cwd.go b/segment-cwd.go index 0022cc9c..8d490767 100644 --- a/segment-cwd.go +++ b/segment-cwd.go @@ -33,12 +33,12 @@ func (s byRevLength) Less(i, j int) bool { func maybeAliasPathSegments(p *powerline, pathSegments []pathSegment) []pathSegment { pathSeparator := string(os.PathSeparator) - if p.pathAliases == nil { + if p.cfg.PathAliases == nil || len(p.cfg.PathAliases) == 0 { return pathSegments } - keys := make([]string, len(p.pathAliases)) - for k := range p.pathAliases { + keys := make([]string, len(p.cfg.PathAliases)) + for k := range p.cfg.PathAliases { keys = append(keys, k) } sort.Sort(byRevLength(keys)) @@ -57,7 +57,7 @@ Aliases: continue Aliases } - alias := p.pathAliases[k] + alias := p.cfg.PathAliases[k] Segments: // We want to see if that array of strings exists in pathSegments. @@ -134,16 +134,16 @@ func cwdToPathSegments(p *powerline, cwd string) []pathSegment { } func maybeShortenName(p *powerline, pathSegment string) string { - if *p.args.CwdMaxDirSize > 0 && len(pathSegment) > *p.args.CwdMaxDirSize { - return pathSegment[:*p.args.CwdMaxDirSize] + if p.cfg.CwdMaxDirSize > 0 && len(pathSegment) > p.cfg.CwdMaxDirSize { + return pathSegment[:p.cfg.CwdMaxDirSize] } return pathSegment } func escapeVariables(p *powerline, pathSegment string) string { - pathSegment = strings.Replace(pathSegment, `\`, p.shellInfo.escapedBackslash, -1) - pathSegment = strings.Replace(pathSegment, "`", p.shellInfo.escapedBacktick, -1) - pathSegment = strings.Replace(pathSegment, `$`, p.shellInfo.escapedDollar, -1) + pathSegment = strings.Replace(pathSegment, `\`, p.shell.EscapedBackslash, -1) + pathSegment = strings.Replace(pathSegment, "`", p.shell.EscapedBacktick, -1) + pathSegment = strings.Replace(pathSegment, `$`, p.shell.EscapedDollar, -1) return pathSegment } @@ -161,7 +161,7 @@ func getColor(p *powerline, pathSegment pathSegment, isLastDir bool) (uint8, uin func segmentCwd(p *powerline) (segments []pwl.Segment) { cwd := p.cwd - if *p.args.CwdMode == "plain" { + if p.cfg.CwdMode == "plain" { if strings.HasPrefix(cwd, p.userInfo.HomeDir) { cwd = "~" + cwd[len(p.userInfo.HomeDir):] } @@ -175,10 +175,10 @@ func segmentCwd(p *powerline) (segments []pwl.Segment) { } else { pathSegments := cwdToPathSegments(p, cwd) - if *p.args.CwdMode == "dironly" { + if p.cfg.CwdMode == "dironly" { pathSegments = pathSegments[len(pathSegments)-1:] } else { - maxDepth := *p.args.CwdMaxDepth + maxDepth := p.cfg.CwdMaxDepth if maxDepth <= 0 { warn("Ignoring -cwd-max-depth argument since it's smaller than or equal to 0") } else if len(pathSegments) > maxDepth { @@ -200,7 +200,7 @@ func segmentCwd(p *powerline) (segments []pwl.Segment) { pathSegments = append(pathSegments, secondPart...) } - if *p.args.CwdMode == "semifancy" && len(pathSegments) > 1 { + if p.cfg.CwdMode == "semifancy" && len(pathSegments) > 1 { var path string for idx, pathSegment := range pathSegments { if pathSegment.home || pathSegment.alias { @@ -234,10 +234,10 @@ func segmentCwd(p *powerline) (segments []pwl.Segment) { if !special { if p.align == alignRight && p.supportsRightModules() && idx != 0 { - segment.Separator = p.symbolTemplates.SeparatorReverseThin + segment.Separator = p.symbols.SeparatorReverseThin segment.SeparatorForeground = p.theme.SeparatorFg } else if (p.align == alignLeft || !p.supportsRightModules()) && !isLastDir { - segment.Separator = p.symbolTemplates.SeparatorThin + segment.Separator = p.symbols.SeparatorThin segment.SeparatorForeground = p.theme.SeparatorFg } } diff --git a/segment-duration.go b/segment-duration.go index de5b2b70..77090110 100644 --- a/segment-duration.go +++ b/segment-duration.go @@ -27,7 +27,7 @@ const ( ) func segmentDuration(p *powerline) []pwl.Segment { - if p.args.Duration == nil || *p.args.Duration == "" { + if p.cfg.Duration == "" { return []pwl.Segment{{ Name: "duration", Content: "No duration", @@ -36,8 +36,8 @@ func segmentDuration(p *powerline) []pwl.Segment { }} } - durationValue := strings.Trim(*p.args.Duration, "'\"") - durationMinValue := strings.Trim(*p.args.DurationMin, "'\"") + durationValue := strings.Trim(p.cfg.Duration, "'\"") + durationMinValue := strings.Trim(p.cfg.DurationMin, "'\"") hasPrecision := strings.Index(durationValue, ".") != -1 @@ -46,7 +46,7 @@ func segmentDuration(p *powerline) []pwl.Segment { if err != nil { return []pwl.Segment{{ Name: "duration", - Content: fmt.Sprintf("Failed to convert '%s' to a number", *p.args.Duration), + Content: fmt.Sprintf("Failed to convert '%s' to a number", p.cfg.Duration), Foreground: p.theme.DurationFg, Background: p.theme.DurationBg, }} diff --git a/segment-exitcode.go b/segment-exitcode.go index 5bda4d52..5b2c2a0c 100644 --- a/segment-exitcode.go +++ b/segment-exitcode.go @@ -31,11 +31,11 @@ func getMeaningFromExitCode(exitCode int) string { func segmentExitCode(p *powerline) []pwl.Segment { var meaning string - if *p.args.PrevError != 0 { - if *p.args.NumericExitCodes { - meaning = strconv.Itoa(*p.args.PrevError) + if p.cfg.PrevError != 0 { + if p.cfg.NumericExitCodes { + meaning = strconv.Itoa(p.cfg.PrevError) } else { - meaning = getMeaningFromExitCode(*p.args.PrevError) + meaning = getMeaningFromExitCode(p.cfg.PrevError) } return []pwl.Segment{{ Name: "exit", diff --git a/segment-git.go b/segment-git.go index 08851f56..84fb2b2c 100644 --- a/segment-git.go +++ b/segment-git.go @@ -42,33 +42,13 @@ func addRepoStatsSegment(nChanges int, symbol string, foreground uint8, backgrou } func (r repoStats) GitSegments(p *powerline) (segments []pwl.Segment) { - ignoreStats := strings.Split(*p.args.GitDisableStats, ",") - for _, stat := range ignoreStats { - // "ahead, behind, staged, notStaged, untracked, conflicted, stashed" - switch stat { - case "ahead": - r.ahead = 0 - case "behind": - r.behind = 0 - case "staged": - r.staged = 0 - case "notStaged": - r.notStaged = 0 - case "untracked": - r.untracked = 0 - case "conflicted": - r.conflicted = 0 - case "stashed": - r.stashed = 0 - } - } - segments = append(segments, addRepoStatsSegment(r.ahead, p.symbolTemplates.RepoAhead, p.theme.GitAheadFg, p.theme.GitAheadBg)...) - segments = append(segments, addRepoStatsSegment(r.behind, p.symbolTemplates.RepoBehind, p.theme.GitBehindFg, p.theme.GitBehindBg)...) - segments = append(segments, addRepoStatsSegment(r.staged, p.symbolTemplates.RepoStaged, p.theme.GitStagedFg, p.theme.GitStagedBg)...) - segments = append(segments, addRepoStatsSegment(r.notStaged, p.symbolTemplates.RepoNotStaged, p.theme.GitNotStagedFg, p.theme.GitNotStagedBg)...) - segments = append(segments, addRepoStatsSegment(r.untracked, p.symbolTemplates.RepoUntracked, p.theme.GitUntrackedFg, p.theme.GitUntrackedBg)...) - segments = append(segments, addRepoStatsSegment(r.conflicted, p.symbolTemplates.RepoConflicted, p.theme.GitConflictedFg, p.theme.GitConflictedBg)...) - segments = append(segments, addRepoStatsSegment(r.stashed, p.symbolTemplates.RepoStashed, p.theme.GitStashedFg, p.theme.GitStashedBg)...) + segments = append(segments, addRepoStatsSegment(r.ahead, p.symbols.RepoAhead, p.theme.GitAheadFg, p.theme.GitAheadBg)...) + segments = append(segments, addRepoStatsSegment(r.behind, p.symbols.RepoBehind, p.theme.GitBehindFg, p.theme.GitBehindBg)...) + segments = append(segments, addRepoStatsSegment(r.staged, p.symbols.RepoStaged, p.theme.GitStagedFg, p.theme.GitStagedBg)...) + segments = append(segments, addRepoStatsSegment(r.notStaged, p.symbols.RepoNotStaged, p.theme.GitNotStagedFg, p.theme.GitNotStagedBg)...) + segments = append(segments, addRepoStatsSegment(r.untracked, p.symbols.RepoUntracked, p.theme.GitUntrackedFg, p.theme.GitUntrackedBg)...) + segments = append(segments, addRepoStatsSegment(r.conflicted, p.symbols.RepoConflicted, p.theme.GitConflictedFg, p.theme.GitConflictedBg)...) + segments = append(segments, addRepoStatsSegment(r.stashed, p.symbols.RepoStashed, p.theme.GitStashedFg, p.theme.GitStashedBg)...) return } @@ -81,13 +61,13 @@ func addRepoStatsSymbol(nChanges int, symbol string) string { func (r repoStats) GitSymbols(p *powerline) string { var info string - info += addRepoStatsSymbol(r.ahead, p.symbolTemplates.RepoAhead) - info += addRepoStatsSymbol(r.behind, p.symbolTemplates.RepoBehind) - info += addRepoStatsSymbol(r.staged, p.symbolTemplates.RepoStaged) - info += addRepoStatsSymbol(r.notStaged, p.symbolTemplates.RepoNotStaged) - info += addRepoStatsSymbol(r.untracked, p.symbolTemplates.RepoUntracked) - info += addRepoStatsSymbol(r.conflicted, p.symbolTemplates.RepoConflicted) - info += addRepoStatsSymbol(r.stashed, p.symbolTemplates.RepoStashed) + info += addRepoStatsSymbol(r.ahead, p.symbols.RepoAhead) + info += addRepoStatsSymbol(r.behind, p.symbols.RepoBehind) + info += addRepoStatsSymbol(r.staged, p.symbols.RepoStaged) + info += addRepoStatsSymbol(r.notStaged, p.symbols.RepoNotStaged) + info += addRepoStatsSymbol(r.untracked, p.symbols.RepoUntracked) + info += addRepoStatsSymbol(r.conflicted, p.symbols.RepoConflicted) + info += addRepoStatsSymbol(r.stashed, p.symbols.RepoStashed) return info } @@ -142,7 +122,7 @@ func getGitDetachedBranch(p *powerline) string { return strings.SplitN(out, "\n", 2)[0] } detachedRef := strings.SplitN(out, "\n", 2) - return fmt.Sprintf("%s %s", p.symbolTemplates.RepoDetached, detachedRef[0]) + return fmt.Sprintf("%s %s", p.symbols.RepoDetached, detachedRef[0]) } func parseGitStats(status []string) repoStats { @@ -203,7 +183,7 @@ func segmentGit(p *powerline) []pwl.Segment { "status", "--porcelain", "-b", "--ignore-submodules", } - if *p.args.GitAssumeUnchangedSize > 0 && indexSize > (*p.args.GitAssumeUnchangedSize*1024) { + if p.cfg.GitAssumeUnchangedSize > 0 && indexSize > (p.cfg.GitAssumeUnchangedSize*1024) { args = append(args, "-uno") } @@ -229,8 +209,8 @@ func segmentGit(p *powerline) []pwl.Segment { branch = getGitDetachedBranch(p) } - if len(p.symbolTemplates.RepoBranch) > 0 { - branch = fmt.Sprintf("%s %s", p.symbolTemplates.RepoBranch, branch) + if len(p.symbols.RepoBranch) > 0 { + branch = fmt.Sprintf("%s %s", p.symbols.RepoBranch, branch) } var foreground, background uint8 @@ -254,7 +234,27 @@ func segmentGit(p *powerline) []pwl.Segment { Background: background, }} - if *p.args.GitMode == "simple" { + for _, stat := range p.cfg.GitDisableStats { + // "ahead, behind, staged, notStaged, untracked, conflicted, stashed" + switch stat { + case "ahead": + stats.ahead = 0 + case "behind": + stats.behind = 0 + case "staged": + stats.staged = 0 + case "notStaged": + stats.notStaged = 0 + case "untracked": + stats.untracked = 0 + case "conflicted": + stats.conflicted = 0 + case "stashed": + stats.stashed = 0 + } + } + + if p.cfg.GitMode == "simple" { if stats.any() { segments[0].Content += " " + stats.GitSymbols(p) } diff --git a/segment-hostname.go b/segment-hostname.go index 1f2f961e..e93d7501 100644 --- a/segment-hostname.go +++ b/segment-hostname.go @@ -22,14 +22,14 @@ func segmentHost(p *powerline) []pwl.Segment { var hostPrompt string var foreground, background uint8 - if *p.args.HostnameOnlyIfSSH { + if p.cfg.HostnameOnlyIfSSH { if os.Getenv("SSH_CLIENT") == "" { // It's not an ssh connection do nothing return []pwl.Segment{} } } - if *p.args.ColorizeHostname { + if p.cfg.ColorizeHostname { hostName := getHostName(p.hostname) hostPrompt = hostName @@ -44,9 +44,9 @@ func segmentHost(p *powerline) []pwl.Segment { foreground = p.theme.HostnameColorizedFgMap[background] } } else { - if p.shell == "bash" { + if p.cfg.Shell == "bash" { hostPrompt = "\\h" - } else if p.shell == "zsh" { + } else if p.cfg.Shell == "zsh" { hostPrompt = "%m" } else { hostPrompt = getHostName(p.hostname) diff --git a/segment-kube.go b/segment-kube.go index 9ca0ab45..b595bd0a 100644 --- a/segment-kube.go +++ b/segment-kube.go @@ -81,7 +81,7 @@ func segmentKube(p *powerline) []pwl.Segment { // When you use gke your clusters may look something like gke_projectname_availability-zone_cluster-01 // instead I want it to read as `cluster-01` // So we remove the first 3 segments of this string, if the flag is set, and there are enough segments - if strings.HasPrefix(cluster, "gke") && *p.args.ShortenGKENames { + if strings.HasPrefix(cluster, "gke") && p.cfg.ShortenGKENames { segments := strings.Split(cluster, "_") if len(segments) > 3 { cluster = strings.Join(segments[3:], "_") @@ -93,7 +93,7 @@ func segmentKube(p *powerline) []pwl.Segment { const arnRegexString string = "^arn:aws:eks:[[:alnum:]-]+:[[:digit:]]+:cluster/(.*)$" arnRe := regexp.MustCompile(arnRegexString) - if arnMatches := arnRe.FindStringSubmatch(cluster); arnMatches != nil && *p.args.ShortenEKSNames { + if arnMatches := arnRe.FindStringSubmatch(cluster); arnMatches != nil && p.cfg.ShortenEKSNames { cluster = arnMatches[1] } segments := []pwl.Segment{} diff --git a/segment-readonly.go b/segment-readonly.go index 3e68dc8d..dcfc6cc7 100644 --- a/segment-readonly.go +++ b/segment-readonly.go @@ -12,7 +12,7 @@ func segmentPerms(p *powerline) []pwl.Segment { if unix.Access(cwd, unix.W_OK) != nil { return []pwl.Segment{{ Name: "perms", - Content: p.symbolTemplates.Lock, + Content: p.symbols.Lock, Foreground: p.theme.ReadonlyFg, Background: p.theme.ReadonlyBg, }} diff --git a/segment-readonly_windows.go b/segment-readonly_windows.go index 36d617d3..38d498bc 100644 --- a/segment-readonly_windows.go +++ b/segment-readonly_windows.go @@ -15,7 +15,7 @@ func segmentPerms(p *powerline) []pwl.Segment { if fileInfo.Mode()&W_USR != W_USR { return []pwl.Segment{{ Name: "perms", - Content: p.symbolTemplates.Lock, + Content: p.symbols.Lock, Foreground: p.theme.ReadonlyFg, Background: p.theme.ReadonlyBg, }} diff --git a/segment-root.go b/segment-root.go index a26aa439..29183b84 100644 --- a/segment-root.go +++ b/segment-root.go @@ -4,7 +4,7 @@ import pwl "github.com/justjanne/powerline-go/powerline" func segmentRoot(p *powerline) []pwl.Segment { var foreground, background uint8 - if *p.args.PrevError == 0 || *p.args.StaticPromptIndicator { + if p.cfg.PrevError == 0 || p.cfg.StaticPromptIndicator { foreground = p.theme.CmdPassedFg background = p.theme.CmdPassedBg } else { @@ -14,7 +14,7 @@ func segmentRoot(p *powerline) []pwl.Segment { return []pwl.Segment{{ Name: "root", - Content: p.shellInfo.rootIndicator, + Content: p.shell.RootIndicator, Foreground: foreground, Background: background, }} diff --git a/segment-shellvar.go b/segment-shellvar.go index 448b0402..3872c6b6 100644 --- a/segment-shellvar.go +++ b/segment-shellvar.go @@ -6,7 +6,7 @@ import ( ) func segmentShellVar(p *powerline) []pwl.Segment { - shellVarName := *p.args.ShellVar + shellVarName := p.cfg.ShellVar varContent, varExists := os.LookupEnv(shellVarName) if varExists { @@ -18,7 +18,7 @@ func segmentShellVar(p *powerline) []pwl.Segment { Background: p.theme.ShellVarBg, }} } - if !*p.args.ShellVarNoWarnEmpty { + if !p.cfg.ShellVarNoWarnEmpty { warn("Shell variable " + shellVarName + " is empty.") } } else { diff --git a/segment-ssh.go b/segment-ssh.go index 38a47f10..a86f8177 100644 --- a/segment-ssh.go +++ b/segment-ssh.go @@ -8,10 +8,10 @@ import ( func segmentSSH(p *powerline) []pwl.Segment { sshClient, _ := os.LookupEnv("SSH_CLIENT") var networkIcon string - if *p.args.SshAlternateIcon { - networkIcon = p.symbolTemplates.NetworkAlternate + if p.cfg.SshAlternateIcon { + networkIcon = p.symbols.NetworkAlternate } else { - networkIcon = p.symbolTemplates.Network + networkIcon = p.symbols.Network } if sshClient != "" { diff --git a/segment-subversion.go b/segment-subversion.go index 7a2e7cb7..6579c991 100644 --- a/segment-subversion.go +++ b/segment-subversion.go @@ -23,13 +23,13 @@ func addSvnRepoStatsSegment(p *powerline, nChanges int, symbol string, foregroun } func (r repoStats) SvnSegments(p *powerline) (segments []pwl.Segment) { - segments = append(segments, addSvnRepoStatsSegment(p, r.ahead, p.symbolTemplates.RepoAhead, p.theme.GitAheadFg, p.theme.GitAheadBg)...) - segments = append(segments, addSvnRepoStatsSegment(p, r.behind, p.symbolTemplates.RepoBehind, p.theme.GitBehindFg, p.theme.GitBehindBg)...) - segments = append(segments, addSvnRepoStatsSegment(p, r.staged, p.symbolTemplates.RepoStaged, p.theme.GitStagedFg, p.theme.GitStagedBg)...) - segments = append(segments, addSvnRepoStatsSegment(p, r.notStaged, p.symbolTemplates.RepoNotStaged, p.theme.GitNotStagedFg, p.theme.GitNotStagedBg)...) - segments = append(segments, addSvnRepoStatsSegment(p, r.untracked, p.symbolTemplates.RepoUntracked, p.theme.GitUntrackedFg, p.theme.GitUntrackedBg)...) - segments = append(segments, addSvnRepoStatsSegment(p, r.conflicted, p.symbolTemplates.RepoConflicted, p.theme.GitConflictedFg, p.theme.GitConflictedBg)...) - segments = append(segments, addSvnRepoStatsSegment(p, r.stashed, p.symbolTemplates.RepoStashed, p.theme.GitStashedFg, p.theme.GitStashedBg)...) + segments = append(segments, addSvnRepoStatsSegment(p, r.ahead, p.symbols.RepoAhead, p.theme.GitAheadFg, p.theme.GitAheadBg)...) + segments = append(segments, addSvnRepoStatsSegment(p, r.behind, p.symbols.RepoBehind, p.theme.GitBehindFg, p.theme.GitBehindBg)...) + segments = append(segments, addSvnRepoStatsSegment(p, r.staged, p.symbols.RepoStaged, p.theme.GitStagedFg, p.theme.GitStagedBg)...) + segments = append(segments, addSvnRepoStatsSegment(p, r.notStaged, p.symbols.RepoNotStaged, p.theme.GitNotStagedFg, p.theme.GitNotStagedBg)...) + segments = append(segments, addSvnRepoStatsSegment(p, r.untracked, p.symbols.RepoUntracked, p.theme.GitUntrackedFg, p.theme.GitUntrackedBg)...) + segments = append(segments, addSvnRepoStatsSegment(p, r.conflicted, p.symbols.RepoConflicted, p.theme.GitConflictedFg, p.theme.GitConflictedBg)...) + segments = append(segments, addSvnRepoStatsSegment(p, r.stashed, p.symbols.RepoStashed, p.theme.GitStashedFg, p.theme.GitStashedBg)...) return segments } diff --git a/segment-termtitle.go b/segment-termtitle.go index 64bae055..4e780034 100644 --- a/segment-termtitle.go +++ b/segment-termtitle.go @@ -19,9 +19,9 @@ func segmentTermTitle(p *powerline) []pwl.Segment { return []pwl.Segment{} } - if p.shell == "bash" { + if p.cfg.Shell == "bash" { title = "\\[\\e]0;\\u@\\h: \\w\\a\\]" - } else if p.shell == "zsh" { + } else if p.cfg.Shell == "zsh" { title = "%{\033]0;%n@%m: %~\007%}" } else { cwd := p.cwd diff --git a/segment-username.go b/segment-username.go index 80c40332..d22e99f1 100644 --- a/segment-username.go +++ b/segment-username.go @@ -6,9 +6,9 @@ import ( func segmentUser(p *powerline) []pwl.Segment { var userPrompt string - if p.shell == "bash" { + if p.cfg.Shell == "bash" { userPrompt = "\\u" - } else if p.shell == "zsh" { + } else if p.cfg.Shell == "zsh" { userPrompt = "%n" } else { userPrompt = p.username diff --git a/segment-virtualenv.go b/segment-virtualenv.go index f97befcc..7ac8188d 100644 --- a/segment-virtualenv.go +++ b/segment-virtualenv.go @@ -24,8 +24,8 @@ func segmentVirtualEnv(p *powerline) []pwl.Segment { segments := []pwl.Segment{} if env != "" { envName := path.Base(env) - if *p.args.VenvNameSizeLimit > 0 && len(envName) > *p.args.VenvNameSizeLimit { - envName = p.symbolTemplates.VenvIndicator + if p.cfg.VenvNameSizeLimit > 0 && len(envName) > p.cfg.VenvNameSizeLimit { + envName = p.symbols.VenvIndicator } segments = append(segments, pwl.Segment{ Name: "venv", diff --git a/themes.go b/themes.go index 2e52e24a..8f69df21 100644 --- a/themes.go +++ b/themes.go @@ -1,7 +1,7 @@ package main // Symbols of the theme -type Symbols struct { +type SymbolTemplate struct { Lock string Network string NetworkAlternate string