fix: restore default config

This commit is contained in:
Jan De Dobbeleer 2022-02-03 21:15:53 +01:00 committed by Jan De Dobbeleer
parent 89619bb2a2
commit fddee51f70

View file

@ -3,12 +3,12 @@ package engine
import ( import (
"bytes" "bytes"
json2 "encoding/json" json2 "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"oh-my-posh/color" "oh-my-posh/color"
"oh-my-posh/console" "oh-my-posh/console"
"oh-my-posh/environment" "oh-my-posh/environment"
"oh-my-posh/properties"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -93,7 +93,7 @@ func loadConfig(env environment.Environment) *Config {
configFile := *env.Args().Config configFile := *env.Args().Config
cfg.eval = *env.Args().Eval cfg.eval = *env.Args().Eval
if configFile == "" { if configFile == "" {
cfg.exitWithError(errors.New("NO CONFIG")) return defaultConfig()
} }
if _, err := os.Stat(configFile); os.IsNotExist(err) { if _, err := os.Stat(configFile); os.IsNotExist(err) {
cfg.exitWithError(err) cfg.exitWithError(err)
@ -220,3 +220,69 @@ func escapeGlyphs(s string) string {
} }
return builder.String() return builder.String()
} }
func defaultConfig() *Config {
cfg := &Config{
Version: 1,
FinalSpace: true,
Blocks: []*Block{
{
Type: Prompt,
Alignment: Left,
Segments: []*Segment{
{
Type: SESSION,
Style: Diamond,
Background: "#c386f1",
Foreground: "#ffffff",
LeadingDiamond: "\uE0B6",
TrailingDiamond: "\uE0B0",
},
{
Type: PATH,
Style: Powerline,
PowerlineSymbol: "\uE0B0",
Background: "#ff479c",
Foreground: "#ffffff",
Properties: properties.Map{
properties.Style: "folder",
},
},
{
Type: SHELL,
Style: Powerline,
PowerlineSymbol: "\uE0B0",
Background: "#0077c2",
Foreground: "#ffffff",
},
{
Type: TEXT,
Style: Powerline,
PowerlineSymbol: "\uE0B0",
Background: "#ffffff",
Foreground: "#111111",
Properties: properties.Map{
properties.SegmentTemplate: " no config ",
},
},
{
Type: EXIT,
Style: Diamond,
Background: "#2e9599",
Foreground: "#ffffff",
LeadingDiamond: "<transparent,background>\uE0B0</>",
TrailingDiamond: "\uE0B4",
BackgroundTemplates: []string{
"{{ if gt .Code 0 }}#f1184c{{ end }}",
},
Properties: properties.Map{
properties.AlwaysEnabled: true,
properties.SegmentTemplate: " \uE23A",
},
},
},
},
},
}
return cfg
}