mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
fix(cmd): insert executable name to avoid spaces in path
relates to #1852
This commit is contained in:
parent
d5da06e33d
commit
a3a9b17f1e
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
|
@ -59,14 +59,14 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Print init pwsh",
|
"name": "Print init",
|
||||||
"type": "go",
|
"type": "go",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "debug",
|
"mode": "debug",
|
||||||
"program": "${workspaceRoot}/src",
|
"program": "${workspaceRoot}/src",
|
||||||
"args": [
|
"args": [
|
||||||
"--print-init",
|
"--print-init",
|
||||||
"--shell=pwsh",
|
"--shell=cmd",
|
||||||
"--config=${workspaceRoot}/themes/jandedobbeleer.omp.json"
|
"--config=${workspaceRoot}/themes/jandedobbeleer.omp.json"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -42,6 +42,12 @@ func getExecutablePath(env environment.Environment) (string, error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
// Intermediate fix for file paths with spaces in CMD
|
||||||
|
// See https://github.com/JanDeDobbeleer/oh-my-posh/issues/1852
|
||||||
|
if *env.Args().Shell == winCMD {
|
||||||
|
fileName := environment.Base(env, executable)
|
||||||
|
return fileName, nil
|
||||||
|
}
|
||||||
// On Windows, it fails when the excutable is called in MSYS2 for example
|
// On Windows, it fails when the excutable is called in MSYS2 for example
|
||||||
// which uses unix style paths to resolve the executable's location.
|
// which uses unix style paths to resolve the executable's location.
|
||||||
// PowerShell knows how to resolve both, so we can swap this without any issue.
|
// PowerShell knows how to resolve both, so we can swap this without any issue.
|
||||||
|
@ -51,7 +57,6 @@ func getExecutablePath(env environment.Environment) (string, error) {
|
||||||
executable = strings.ReplaceAll(executable, " ", "\\ ")
|
executable = strings.ReplaceAll(executable, " ", "\\ ")
|
||||||
executable = strings.ReplaceAll(executable, "(", "\\(")
|
executable = strings.ReplaceAll(executable, "(", "\\(")
|
||||||
executable = strings.ReplaceAll(executable, ")", "\\)")
|
executable = strings.ReplaceAll(executable, ")", "\\)")
|
||||||
return executable, nil
|
|
||||||
}
|
}
|
||||||
return executable, nil
|
return executable, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue