summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2025-12-15 16:48:57 +0800
committerGitHub <[email protected]>2025-12-15 16:48:57 +0800
commitbab1a618ff5ef169f93d561eb91e42da3fe722ec (patch)
treeea2b1df9e3c38ccf3f9ab6281054a6b3706ccd1f /xmake/core
parente58fd4cd9145d5a060a00c513cbe76a1011c013f (diff)
parent5ddfccee2173989269704dfc463c948b8bd6653e (diff)
Merge pull request #7135 from xmake-io/session
Improve `xrepo env` to add session id
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/base/tty.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/xmake/core/base/tty.lua b/xmake/core/base/tty.lua
index d35705770..dd053b3e6 100644
--- a/xmake/core/base/tty.lua
+++ b/xmake/core/base/tty.lua
@@ -26,6 +26,7 @@ local io = require("base/io")
-- save metatable and builtin functions
tty._term_mode = tty._term_mode or tty.term_mode
+tty._session_id = tty._session_id or tty.session_id
-- @see https://www2.ccs.neu.edu/research/gpc/VonaUtils/vona/terminal/vtansi.htm
-- http://www.termsys.demon.co.uk/vtansi.htm
@@ -538,6 +539,25 @@ function tty.term_mode(stdtype, newmode)
return oldmode
end
+-- get session id
+function tty.session_id()
+ local session_id = tty._SESSION_ID
+ if session_id == nil then
+ if tty._session_id then
+ local sid = tty._session_id()
+ if sid then
+ local hash = require("base/hash")
+ session_id = hash.strhash32(sid)
+ end
+ end
+ if not session_id then
+ session_id = "00000000"
+ end
+ tty._SESSION_ID = session_id
+ end
+ return session_id
+end
+
-- return module
return tty