mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
parent
a3a9b17f1e
commit
ee2b6e3f14
|
@ -42,12 +42,6 @@ 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.
|
||||||
|
|
|
@ -5,13 +5,19 @@ local last_duration
|
||||||
local tip_word
|
local tip_word
|
||||||
|
|
||||||
local function omp_exe()
|
local function omp_exe()
|
||||||
return [[::OMP::]]
|
return [["::OMP::"]]
|
||||||
end
|
end
|
||||||
|
|
||||||
local function omp_config()
|
local function omp_config()
|
||||||
return [[::CONFIG::]]
|
return [[::CONFIG::]]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function run_posh_command(command)
|
||||||
|
command = '"'..command..'"'
|
||||||
|
output = io.popen(command):read("*a")
|
||||||
|
return output
|
||||||
|
end
|
||||||
|
|
||||||
local function os_clock_millis()
|
local function os_clock_millis()
|
||||||
-- Clink v1.2.30 has a fix for Lua's os.clock() implementation failing after
|
-- Clink v1.2.30 has a fix for Lua's os.clock() implementation failing after
|
||||||
-- the program has been running more than 24 days. In older versions, call
|
-- the program has been running more than 24 days. In older versions, call
|
||||||
|
@ -19,7 +25,8 @@ local function os_clock_millis()
|
||||||
if (clink.version_encoded or 0) >= 10020030 then
|
if (clink.version_encoded or 0) >= 10020030 then
|
||||||
return math.floor(os.clock() * 1000)
|
return math.floor(os.clock() * 1000)
|
||||||
else
|
else
|
||||||
return io.popen(omp_exe().." --millis"):read("*n")
|
local prompt_exe = string.format('%s --millis', omp_exe())
|
||||||
|
return run_posh_command(prompt_exe)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -56,8 +63,7 @@ end
|
||||||
|
|
||||||
local function get_posh_prompt(rprompt)
|
local function get_posh_prompt(rprompt)
|
||||||
local prompt_exe = string.format('%s --shell=cmd --config="%s" %s %s --rprompt=%s', omp_exe(), omp_config(), execution_time_option(), error_level_option(), rprompt)
|
local prompt_exe = string.format('%s --shell=cmd --config="%s" %s %s --rprompt=%s', omp_exe(), omp_config(), execution_time_option(), error_level_option(), rprompt)
|
||||||
prompt = io.popen(prompt_exe):read("*a")
|
return run_posh_command(prompt_exe)
|
||||||
return prompt
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local p = clink.promptfilter(1)
|
local p = clink.promptfilter(1)
|
||||||
|
@ -69,7 +75,7 @@ function p:rightfilter(prompt)
|
||||||
return get_posh_prompt(true), false
|
return get_posh_prompt(true), false
|
||||||
end
|
end
|
||||||
local prompt_exe = string.format('%s --shell=cmd --config="%s" --command="%s"', omp_exe(), omp_config(), tip_word)
|
local prompt_exe = string.format('%s --shell=cmd --config="%s" --command="%s"', omp_exe(), omp_config(), tip_word)
|
||||||
tooltip = io.popen(prompt_exe):read("*a")
|
tooltip = run_posh_command(prompt_exe)
|
||||||
if tooltip ~= "" then
|
if tooltip ~= "" then
|
||||||
return tooltip, false
|
return tooltip, false
|
||||||
end
|
end
|
||||||
|
@ -77,7 +83,7 @@ function p:rightfilter(prompt)
|
||||||
end
|
end
|
||||||
function p:transientfilter(prompt)
|
function p:transientfilter(prompt)
|
||||||
local prompt_exe = string.format('%s --shell=cmd --config="%s" --print-transient', omp_exe(), omp_config())
|
local prompt_exe = string.format('%s --shell=cmd --config="%s" --print-transient', omp_exe(), omp_config())
|
||||||
prompt = io.popen(prompt_exe):read("*a")
|
prompt = run_posh_command(prompt_exe)
|
||||||
if prompt == "" then
|
if prompt == "" then
|
||||||
prompt = nil
|
prompt = nil
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue