feat: move default theme internally

This commit is contained in:
Jan De Dobbeleer 2022-10-12 14:59:37 +02:00 committed by Jan De Dobbeleer
parent ac0ffec43a
commit 6980cb55e7
4 changed files with 150 additions and 219 deletions

View file

@ -8,6 +8,7 @@ import (
"oh-my-posh/color"
"oh-my-posh/environment"
"oh-my-posh/properties"
"oh-my-posh/segments"
"os"
"path/filepath"
"strings"
@ -242,53 +243,174 @@ func defaultConfig() *Config {
{
Type: SESSION,
Style: Diamond,
Background: "#c386f1",
Foreground: "#ffffff",
LeadingDiamond: "\uE0B6",
TrailingDiamond: "\uE0B0",
LeadingDiamond: "\ue0b6",
TrailingDiamond: "\ue0b0",
Background: "p:yellow",
Foreground: "p:black",
Template: " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }} ",
},
{
Type: PATH,
Style: Powerline,
PowerlineSymbol: "\uE0B0",
Background: "#ff479c",
Foreground: "#ffffff",
PowerlineSymbol: "\ue0b0",
Background: "p:orange",
Foreground: "p:white",
Properties: properties.Map{
properties.Style: "folder",
},
Template: " \uf74a {{ path .Path .Location }} ",
},
{
Type: SHELL,
Type: GIT,
Style: Powerline,
PowerlineSymbol: "\uE0B0",
Background: "#0077c2",
Foreground: "#ffffff",
PowerlineSymbol: "\ue0b0",
Background: "p:green",
BackgroundTemplates: []string{
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:yellow{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:red{{ end }}",
"{{ if gt .Ahead 0 }}#49416D{{ end }}",
"{{ if gt .Behind 0 }}#7A306C{{ end }}",
},
Foreground: "p:black",
ForegroundTemplates: []string{
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:black{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:white{{ end }}",
"{{ if gt .Ahead 0 }}p:white{{ end }}",
},
Properties: properties.Map{
segments.BranchMaxLength: 25,
segments.FetchStatus: true,
segments.FetchUpstreamIcon: true,
segments.GithubIcon: "\uf7a3",
},
Template: " {{ if .UpstreamURL }}{{ url .UpstreamIcon .UpstreamURL }} {{ end }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }} ", //nolint:lll
},
{
Type: TEXT,
Type: ROOT,
Style: Powerline,
PowerlineSymbol: "\uE0B0",
Background: "#ffffff",
Foreground: "#111111",
Template: " no config ",
PowerlineSymbol: "\ue0b0",
Background: "p:yellow",
Foreground: "p:white",
Template: " \uf0e7 ",
},
{
Type: EXIT,
Style: Diamond,
Background: "#2e9599",
Foreground: "#ffffff",
LeadingDiamond: "<transparent,background>\uE0B0</>",
TrailingDiamond: "\uE0B4",
LeadingDiamond: "<transparent,background>\ue0b0</>",
TrailingDiamond: "\ue0b4",
Background: "p:blue",
BackgroundTemplates: []string{
"{{ if gt .Code 0 }}#f1184c{{ end }}",
"{{ if gt .Code 0 }}p:red{{ end }}",
},
Template: " \uE23A ",
Foreground: "p:white",
Properties: properties.Map{
properties.AlwaysEnabled: true,
},
Template: " {{ if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} ",
},
},
},
{
Type: RPrompt,
Segments: []*Segment{
{
Type: NODE,
Style: Plain,
Background: "transparent",
Foreground: "p:green",
Template: "\uf898 ",
Properties: properties.Map{
segments.HomeEnabled: false,
segments.FetchPackageManager: false,
segments.DisplayMode: "files",
},
},
{
Type: GOLANG,
Style: Plain,
Background: "transparent",
Foreground: "p:blue",
Template: "\ufcd1 ",
Properties: properties.Map{
properties.FetchVersion: false,
},
},
{
Type: PYTHON,
Style: Plain,
Background: "transparent",
Foreground: "p:yellow",
Template: "\ue235 ",
Properties: properties.Map{
properties.FetchVersion: false,
segments.DisplayMode: "files",
segments.FetchVirtualEnv: false,
},
},
{
Type: SHELL,
Style: Plain,
Background: "transparent",
Foreground: "p:white",
Template: "in <p:blue><b>{{ .Name }}</b></> ",
},
{
Type: TIME,
Style: Plain,
Background: "transparent",
Foreground: "p:white",
Template: "at <p:blue><b>{{ .CurrentDate | date \"15:04:05\" }}</b></>",
},
},
},
},
ConsoleTitleTemplate: "{{ .Shell }} in {{ .Folder }}",
Palette: color.Palette{
"black": "#262B44",
"blue": "#4B95E9",
"green": "#59C9A5",
"orange": "#F07623",
"red": "#D81E5B",
"white": "#E0DEF4",
"yellow": "#F3AE35",
},
SecondaryPrompt: &Segment{
Background: "transparent",
Foreground: "p:black",
Template: "<p:yellow,transparent>\ue0b6</><,p:yellow> > </><p:yellow,transparent>\ue0b0</> ",
},
TransientPrompt: &Segment{
Background: "transparent",
Foreground: "p:black",
Template: "<p:yellow,transparent>\ue0b6</><,p:yellow> {{ .Folder }} </><p:yellow,transparent>\ue0b0</> ",
},
Tooltips: []*Segment{
{
Type: AWS,
Style: Diamond,
LeadingDiamond: "\ue0b0",
TrailingDiamond: "\ue0b4",
Background: "p:orange",
Foreground: "p:white",
Template: " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ",
Properties: properties.Map{
properties.DisplayDefault: true,
},
Tips: []string{"aws"},
},
{
Type: AZ,
Style: Diamond,
LeadingDiamond: "\ue0b0",
TrailingDiamond: "\ue0b4",
Background: "p:blue",
Foreground: "p:white",
Template: " \ufd03 {{ .Name }} ",
Properties: properties.Map{
properties.DisplayDefault: true,
},
Tips: []string{"az"},
},
},
}
return cfg

View file

@ -254,7 +254,7 @@ func (env *ShellEnvironment) resolveConfigPath() {
env.CmdFlags.Config = env.Getenv("POSH_THEME")
}
if len(env.CmdFlags.Config) == 0 {
env.CmdFlags.Config = fmt.Sprintf("https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/v%s/themes/default.omp.json", env.Version)
return
}
if strings.HasPrefix(env.CmdFlags.Config, "https://") {
if err := env.downloadConfig(env.CmdFlags.Config); err != nil {

View file

@ -1,190 +0,0 @@
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "p:yellow",
"foreground": "p:black",
"leading_diamond": "\ue0b6",
"properties": {
"display_host": false
},
"style": "diamond",
"template": " {{ if .SSHSession }}\uf817 {{ end }}{{ .UserName }} ",
"trailing_diamond": "\ue0b0",
"type": "session"
},
{
"background": "p:orange",
"foreground": "p:white",
"powerline_symbol": "\ue0b0",
"properties": {
"home_icon": "~",
"style": "folder"
},
"style": "powerline",
"template": " \uf74a {{ path .Path .Location }} ",
"type": "path"
},
{
"background": "p:green",
"background_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:yellow{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:red{{ end }}",
"{{ if gt .Ahead 0 }}#49416D{{ end }}",
"{{ if gt .Behind 0 }}#7A306C{{ end }}"
],
"foreground": "p:black",
"foreground_templates": [
"{{ if or (.Working.Changed) (.Staging.Changed) }}p:black{{ end }}",
"{{ if and (gt .Ahead 0) (gt .Behind 0) }}p:white{{ end }}",
"{{ if gt .Ahead 0 }}p:white{{ end }}"
],
"powerline_symbol": "\ue0b0",
"properties": {
"branch_max_length": 25,
"fetch_status": true,
"fetch_upstream_icon": true,
"github_icon": "\uf7a3"
},
"style": "powerline",
"template": " {{ if .UpstreamURL }}{{ url .UpstreamIcon .UpstreamURL }} {{ end }}{{ .HEAD }}{{if .BranchStatus }} {{ .BranchStatus }}{{ end }}{{ if .Working.Changed }} \uf044 {{ .Working.String }}{{ end }}{{ if .Staging.Changed }} \uf046 {{ .Staging.String }}{{ end }} ",
"type": "git"
},
{
"background": "p:yellow",
"foreground": "p:white",
"powerline_symbol": "\ue0b0",
"properties": {
"root_icon": "\uf0ad"
},
"style": "powerline",
"template": " \uf0e7 ",
"type": "root"
},
{
"background": "p:blue",
"background_templates": [
"{{ if gt .Code 0 }}p:red{{ end }}"
],
"foreground": "p:white",
"leading_diamond": "<transparent,background>\ue0b0</>",
"properties": {
"always_enabled": true
},
"style": "diamond",
"template": " {{ if gt .Code 0 }}\uf00d{{ else }}\uf00c{{ end }} ",
"trailing_diamond": "\ue0b4",
"type": "exit"
}
],
"type": "prompt"
},
{
"segments": [
{
"background": "transparent",
"foreground": "p:green",
"properties": {
"display_mode": "files",
"fetch_package_manager": false,
"home_enabled": false
},
"style": "plain",
"template": "\uf898 ",
"type": "node"
},
{
"background": "transparent",
"foreground": "p:blue",
"properties": {
"fetch_version": false
},
"style": "powerline",
"template": "\ufcd1 ",
"type": "go"
},
{
"background": "transparent",
"foreground": "p:yellow",
"properties": {
"display_mode": "files",
"fetch_version": true,
"fetch_virtual_env": false
},
"style": "plain",
"template": "\ue235 ",
"type": "python"
},
{
"background": "transparent",
"foreground": "p:white",
"style": "plain",
"template": "in <p:blue><b>{{ .Name }}</b></> ",
"type": "shell"
},
{
"background": "transparent",
"foreground": "p:white",
"style": "plain",
"template": "at <p:blue><b>{{ .CurrentDate | date \"15:04:05\" }}</b></>",
"type": "time"
}
],
"type": "rprompt"
}
],
"console_title_template": "{{ .Shell }} in {{ .Folder }}",
"final_space": true,
"palette": {
"black": "#262B44",
"blue": "#4B95E9",
"green": "#59C9A5",
"orange": "#F07623",
"red": "#D81E5B",
"white": "#E0DEF4",
"yellow": "#F3AE35"
},
"secondary_prompt": {
"background": "transparent",
"foreground": "p:black",
"template": "<p:yellow,transparent>\ue0b6</><,p:yellow> > </><p:yellow,transparent>\ue0b0</> "
},
"tooltips": [
{
"background": "p:orange",
"foreground": "p:white",
"leading_diamond": "\ue0b6",
"properties": {
"display_default": true
},
"style": "diamond",
"template": " \ue7ad {{ .Profile }}{{ if .Region }}@{{ .Region }}{{ end }} ",
"tips": [
"aws"
],
"trailing_diamond": "\ue0b4",
"type": "aws"
},
{
"background": "p:blue",
"foreground": "p:white",
"leading_diamond": "\ue0b6",
"style": "diamond",
"template": " \ufd03 {{ .Name }} ",
"tips": [
"az"
],
"trailing_diamond": "\ue0b4",
"type": "az"
}
],
"transient_prompt": {
"background": "transparent",
"foreground": "p:black",
"template": "<p:yellow,transparent>\ue0b6</><,p:yellow> {{ .Folder }} </><p:yellow,transparent>\ue0b0</> "
},
"version": 2
}

View file

@ -7,12 +7,12 @@ sidebar_label: 💅🏼 Customize
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem"
The standard initialization sets Oh My Posh' [default theme][default-theme]. This configuration is downloaded
and kept up-to-date with Oh My Posh' version every time the shell starts.
The standard initialization sets Oh My Posh' default theme. This configuration is embedded
and thus kept up-to-date with Oh My Posh.
To set a new config/theme you need
to change the `--config` option of the `oh-my-posh init <shell>` line in your `profile` or `.<shell>rc` script
(see [prompt][prompt]) and point it to the location of a predefined [theme][themes] or custom configuration.
To set a new config/theme you need to change the `--config` option of the `oh-my-posh init <shell>`
line in your `profile` or `.<shell>rc` script (see [prompt][prompt]) and point it to the location of a
predefined [theme][themes] or custom configuration.
There are two possible values the `--config` flag can handle:
@ -241,7 +241,6 @@ segments section covers how to configure each available segment.
[themes]: themes.md
[configuration]: configuration/overview.mdx
[prompt]: prompt.mdx
[default-theme]: https://github.com/JanDeDobbeleer/oh-my-posh/blob/main/themes/default.omp.json
[jandedobbeleer]: /docs/themes#jandedobbeleer
[json-schema]: https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
[homebrew-problem]: https://github.com/JanDeDobbeleer/oh-my-posh/discussions/2644