Skip to content

Commit 12fdad1

Browse files
committed
➖ Remove lsb_release
1 parent 47a901c commit 12fdad1

File tree

1 file changed

+108
-9
lines changed

1 file changed

+108
-9
lines changed

lua/prompt/style.lua

+108-9
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,85 @@ end
2929
---get distribution
3030
---@return string
3131
local function get_distribution()
32-
local line = io.popen("lsb_release -i 2>/dev/null"):read()
33-
if line == nil then return "linux" end
34-
return line:gsub(".*:%s*", ""):lower()
32+
local f = io.open("/etc/artix-release")
33+
if f then
34+
f:close()
35+
return "artix"
36+
end
37+
f = io.open("/etc/os-release")
38+
if f == nil then
39+
f = io.open("/usr/lib/os-release")
40+
end
41+
if f then
42+
local result
43+
for line in f:lines() do
44+
if line:match("^ID=") then
45+
result = line:gsub("^ID=", "")
46+
break
47+
end
48+
end
49+
f:close()
50+
if result:match("arch") then
51+
return "arch"
52+
elseif result:match("debian") then
53+
return "debian"
54+
elseif result:match("raspbian") then
55+
return "raspbian"
56+
elseif result:match("ubuntu") then
57+
return "ubuntu"
58+
elseif result:match("elementary") then
59+
return "elementary"
60+
elseif result:match("fedora") then
61+
return "fedora"
62+
elseif result:match("coreos") then
63+
return "coreos"
64+
elseif result:match("kali") then
65+
return "kali"
66+
elseif result:match("gentoo") then
67+
return "gentoo"
68+
elseif result:match("mageia") then
69+
return "mageia"
70+
elseif result:match("centos") then
71+
return "centos"
72+
elseif result:match("opensuse") then
73+
return "opensuse"
74+
elseif result:match("tumbleweed") then
75+
return "opensuse"
76+
elseif result:match("sabayon") then
77+
return "sabayon"
78+
elseif result:match("slackware") then
79+
return "slackware"
80+
elseif result:match("linuxmint") then
81+
return "mint"
82+
elseif result:match("alpine") then
83+
return "alpine"
84+
elseif result:match("aosc") then
85+
return "aosc"
86+
elseif result:match("nixos") then
87+
return "nixos"
88+
elseif result:match("devuan") then
89+
return "devuan"
90+
elseif result:match("manjaro") then
91+
return "manjaro"
92+
elseif result:match("void") then
93+
return "void"
94+
elseif result:match("artix") then
95+
return "artix"
96+
elseif result:match("rhel") then
97+
return "rhel"
98+
elseif result:match("amzn") then
99+
return "amzn"
100+
elseif result:match("endeavouros") then
101+
return "endeavouros"
102+
elseif result:match("rocky") then
103+
return "rocky"
104+
elseif result:match("guix") then
105+
return "guix"
106+
elseif result:match("dock") then
107+
return "docker"
108+
end
109+
end
110+
return "linux"
35111
end
36112

37113
---get os
@@ -40,7 +116,7 @@ local function get_os()
40116
if os.getenv("PREFIX") == "/data/data/com.termux/files/usr" then
41117
return "android"
42118
end
43-
local binary_format = package.cpath:match('([^.]+)[;|$]')
119+
local binary_format = package.cpath:match('([^.]+)$')
44120
if binary_format == "so" then
45121
return get_distribution()
46122
elseif binary_format == "dll" then
@@ -56,17 +132,40 @@ end
56132
local function get_icon()
57133
local icons = {
58134
unknown = "?",
59-
android = "",
135+
alpine = "",
136+
amzn = "",
137+
android = "",
138+
aosc = "",
60139
arch = "",
140+
artix = "",
61141
centos = "",
142+
coreos = "",
62143
debian = "",
144+
devuan = "",
63145
docker = "",
146+
elementary = "",
147+
endeavouros = "",
148+
fedora = "",
149+
freebsd = "",
64150
gentoo = "",
65-
linux = "",
66-
macos = "",
67-
ubuntu = "",
151+
guix = "",
152+
kali = "",
153+
linux = "",
154+
macos = "",
155+
mageia = "",
156+
manjaro = "",
157+
mint = "",
68158
nixos = "",
69-
windows = ""
159+
opensuse = "",
160+
raspbian = "",
161+
rhel = "",
162+
rocky = "",
163+
sabayon = "",
164+
slackware = "",
165+
sunos = "",
166+
ubuntu = "",
167+
void = "",
168+
windows = "",
70169
}
71170
return icons[get_os()]
72171
end

0 commit comments

Comments
 (0)