11--- prompt style.
22local os = require " os"
3- local table = require " table"
4- local lfs = require " lfs"
3+
4+ local lfs = require " lfs"
5+ local uv = require " platformdirs.uv"
56local warna = require " warna"
67warna .options .level = 3
78local ansicolors = warna .format
89local prompt = require " prompt"
9- --- @diagnostic disable : deprecated
10- if table.unpack == nil then table .unpack = unpack end
1110
1211--- wakatime
1312--- @param cmd string | nil
@@ -121,15 +120,15 @@ end
121120--- get os
122121--- @return string
123122local function get_os ()
124- if os.getenv (" PREFIX " ) == " /data/data/com.termux/files/usr " then
123+ if os.getenv (" ANDROID_DATA " ) == " /data" and os.getenv ( " ANDROID_ROOT " ) == " /system " then
125124 return " android"
126125 end
127- local binary_format = package.cpath : match ( ' ([^.]+);?$ ' )
128- if binary_format == " so " then
126+ local sysname = uv . os_uname (). sysname : lower ( )
127+ if sysname : find ( ' linux ' ) or sysname : find ( ' unix ' ) then
129128 return get_distribution ()
130- elseif binary_format == " dll " then
129+ elseif sysname : find ( ' windows ' ) or sysname : find ( ' mingw ' ) then
131130 return " windows"
132- elseif binary_format == " dylib " then
131+ elseif sysname : find ( ' macos ' ) then
133132 return " macos"
134133 end
135134 return " unknown"
@@ -219,11 +218,11 @@ end
219218local function generate_ps1 (char , sections )
220219 char = char or " ❯ "
221220 sections = sections or {
222- --- @diagnostic disable : missing-parameter
223- { " " , " " , wakatime },
224- { " black" , " yellow" , get_icon () }, { " blue" , " black" , get_version () },
225- { " white" , " blue" , get_cwd }, { " black" , " white" , get_time }
226- }
221+ --- @diagnostic disable : missing-parameter
222+ { " " , " " , wakatime },
223+ { " black" , " yellow" , get_icon () }, { " blue" , " black" , get_version () },
224+ { " white" , " blue" , get_cwd }, { " black" , " white" , get_time }
225+ }
227226 local sep = " "
228227 local format = " %s "
229228 return function ()
@@ -237,7 +236,9 @@ local function generate_ps1(char, sections)
237236 sep = v
238237 end
239238 else
240- local fg , bg , text = table.unpack (v )
239+ local fg = v [1 ]
240+ local bg = v [2 ]
241+ local text = v [3 ]
241242 if type (text ) == " function" then text = text () end
242243 if text ~= " " then
243244 text = format :format (text )
0 commit comments