diff options
| author | xq114 <[email protected]> | 2021-04-16 13:07:55 +0800 |
|---|---|---|
| committer | xq114 <[email protected]> | 2021-04-16 13:07:55 +0800 |
| commit | 0ba602c1fdb417188c215ccda4b342549da9924d (patch) | |
| tree | f31e2f10e71bbafe9b90fe19c0715c881374095a /xmake/core/base/tty.lua | |
| parent | b335fe5f2a21b0663fe0347069940ed5e7f5f5f8 (diff) | |
add os.shell
Diffstat (limited to 'xmake/core/base/tty.lua')
| -rw-r--r-- | xmake/core/base/tty.lua | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua index 074c6e31a..b18ef540a 100644 --- a/xmake/core/base/tty.lua +++ b/xmake/core/base/tty.lua @@ -125,6 +125,32 @@ function tty.flush() return tty 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 + 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" + end + end + end + return "sh" +end + -- get terminal name -- - xterm -- - cmd @@ -132,6 +158,7 @@ end -- - vscode (in vscode) -- - msys2 -- - cygwin +-- - pwsh -- - powershell -- - mintty -- - windows-terminal @@ -179,11 +206,8 @@ function tty.term() term = "vstudio" elseif os.getenv("WT_SESSION") then term = "windows-terminal" - elseif os.getenv("PROMPT") then -- $PROMPT == "$P$G" - term = "cmd" else - -- TODO maybe powershell if no $PROMPT, we need improve it - term = "powershell" + term = tty.shell() end elseif subhost == "msys" then term = "msys2" |
