From 2c1d5cf6e4bb079b8ed6fe13019b59b05713e2a2 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Fri, 19 Nov 2021 08:45:15 +0100 Subject: [PATCH] fix(cmd): allow all types of path separators --- src/init/omp.lua | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/init/omp.lua b/src/init/omp.lua index eceed4b6..e8032f7f 100644 --- a/src/init/omp.lua +++ b/src/init/omp.lua @@ -4,6 +4,14 @@ local endedit_time local last_duration local tip_word +local function omp_exe() + return [[::OMP::]] +end + +local function omp_config() + return [[::CONFIG::]] +end + local function os_clock_millis() -- 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 @@ -11,7 +19,7 @@ local function os_clock_millis() if (clink.version_encoded or 0) >= 10020030 then return math.floor(os.clock() * 1000) else - return io.popen("::OMP:: --millis"):read("*n") + return io.popen(omp_exe().." --millis"):read("*n") end end @@ -47,7 +55,7 @@ local function error_level_option() end local function get_posh_prompt(rprompt) - local prompt_exe = string.format('::OMP:: --shell=cmd --config="::CONFIG::" %s %s --rprompt=%s', 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 prompt end @@ -60,7 +68,7 @@ function p:rightfilter(prompt) if tip_word == nil then return get_posh_prompt(true), false end - local prompt_exe = string.format('::OMP:: --shell=cmd --config="::CONFIG::" --command="%s"', 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") if tooltip ~= "" then return tooltip, false @@ -68,7 +76,8 @@ function p:rightfilter(prompt) return get_posh_prompt(true), false end function p:transientfilter(prompt) - prompt = io.popen('::OMP:: --shell=cmd --config="::CONFIG::" --print-transient'):read("*a") + local prompt_exe = string.format('%s --shell=cmd --config="%s" --print-transient', omp_exe(), omp_config()) + prompt = io.popen(prompt_exe):read("*a") if prompt == "" then prompt = nil end