diff options
| author | xq114 <[email protected]> | 2021-04-16 13:24:11 +0800 |
|---|---|---|
| committer | xq114 <[email protected]> | 2021-04-16 13:24:11 +0800 |
| commit | 042b301bd2042cf19207096ceafc30be3dbd0658 (patch) | |
| tree | 3701a9c5171a129b4107b99f7d98eb07850f67d1 | |
| parent | 0ba602c1fdb417188c215ccda4b342549da9924d (diff) | |
add cache to tty.shell
| -rw-r--r-- | xmake/core/base/tty.lua | 42 | ||||
| -rw-r--r-- | xmake/themes/default/xmake.lua | 2 |
2 files changed, 25 insertions, 19 deletions
diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua index b18ef540a..30b6abb99 100644 --- a/xmake/core/base/tty.lua +++ b/xmake/core/base/tty.lua @@ -127,28 +127,34 @@ end -- get shell name function tty.shell() - local shell = os.getenv("SHELL") - if shell then - for _, shellname in ipairs({"zsh", "bash", "sh"}) do - if shell:find(shellname) then - return shellname + local shell = tty._SHELL + if shell == nil then + local subhost = xmake._SUBHOST + if subhost == "windows" then + if os.getenv("PROMPT") then + shell = "cmd" + else + local ok, result = os.iorun("pwsh -v") + if ok then + shell = "pwsh" + else + shell = "powershell" + end end - end - end - local subhost = xmake._SUBHOST - if subhost == "windows" then - if os.getenv("PROMPT") then - return "cmd" else - local ok, result = os.iorun("pwsh -v") - if ok then - return "pwsh" - else - return "powershell" + shell = os.getenv("SHELL") + if shell then + for _, shellname in ipairs({"zsh", "bash", "sh"}) do + if shell:find(shellname) then + shell = shellname + break + end + end end end + tty._SHELL = shell or "sh" end - return "sh" + return tty._SHELL end -- get terminal name @@ -219,7 +225,7 @@ function tty.term() end tty._TERM = term or "unknown" end - return term + return tty._TERM end -- has emoji? diff --git a/xmake/themes/default/xmake.lua b/xmake/themes/default/xmake.lua index 3434c6e03..554b15c1a 100644 --- a/xmake/themes/default/xmake.lua +++ b/xmake/themes/default/xmake.lua @@ -77,7 +77,7 @@ theme("default") set_color("dump.function", "cyan") -- menu - if is_subhost("windows") and os.term() == "powershell" then + if is_subhost("windows") and (os.term() == "powershell" or os.term() == "pwsh") then set_color("menu.main.task.name", "cyan bright") set_color("menu.option.name", "green bright") else |
