mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-30 04:21:19 -08:00
fix(config): resolve path for all shells
This commit is contained in:
parent
5549e0d7ad
commit
7aaa7b110f
|
@ -164,6 +164,7 @@ type environment struct {
|
|||
|
||||
func (env *environment) init(args *args) {
|
||||
env.args = args
|
||||
env.resolveConfigPath()
|
||||
env.cmdCache = &commandCache{
|
||||
commands: newConcurrentMap(),
|
||||
}
|
||||
|
@ -175,6 +176,23 @@ func (env *environment) init(args *args) {
|
|||
env.fileCache.init(env.getCachePath())
|
||||
}
|
||||
|
||||
func (env *environment) resolveConfigPath() {
|
||||
if env.args == nil || env.args.Config == nil {
|
||||
return
|
||||
}
|
||||
configFile := *env.args.Config
|
||||
if strings.HasPrefix(configFile, "~") {
|
||||
configFile = strings.TrimPrefix(configFile, "~")
|
||||
configFile = filepath.Join(env.homeDir(), configFile)
|
||||
}
|
||||
if !filepath.IsAbs(configFile) {
|
||||
if absConfigFile, err := filepath.Abs(configFile); err == nil {
|
||||
configFile = absConfigFile
|
||||
}
|
||||
}
|
||||
*env.args.Config = filepath.Clean(configFile)
|
||||
}
|
||||
|
||||
func (env *environment) trace(start time.Time, function string, args ...string) {
|
||||
if !env.debug {
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue