2020-07-27 09:07:34 +03:00
|
|
|
function _tide_detect_os
|
2020-07-30 03:30:32 +03:00
|
|
|
switch (uname | string lower)
|
|
|
|
case darwin
|
2021-09-08 20:54:31 +03:00
|
|
|
echo -ns
|
2020-07-30 03:30:32 +03:00
|
|
|
case freebsd openbsd dragonfly
|
2021-09-08 20:54:31 +03:00
|
|
|
echo -ns
|
2020-07-30 03:30:32 +03:00
|
|
|
case linux
|
2020-12-26 03:32:03 +03:00
|
|
|
_tide_detect_os_linux_cases /etc/os-release ID ||
|
2021-03-02 20:46:40 +03:00
|
|
|
_tide_detect_os_linux_cases /etc/os-release ID_LIKE ||
|
|
|
|
_tide_detect_os_linux_cases /etc/lsb-release DISTRIB_ID ||
|
2021-09-08 20:54:31 +03:00
|
|
|
echo -ns
|
2020-07-27 09:07:34 +03:00
|
|
|
case '*'
|
2021-09-08 20:54:31 +03:00
|
|
|
echo -ns '?'
|
2020-07-27 09:07:34 +03:00
|
|
|
end
|
2020-07-30 03:30:32 +03:00
|
|
|
end
|
|
|
|
|
2020-09-23 23:48:55 +03:00
|
|
|
function _tide_detect_os_linux_cases -a file key
|
2021-03-21 04:03:07 +03:00
|
|
|
test -e $file || return
|
2021-05-12 23:13:51 +03:00
|
|
|
set -l split_file (string split '=' <$file)
|
|
|
|
set -l key_index (contains --index $key $split_file) || return
|
|
|
|
set -l value (string trim --chars='"' $split_file[(math $key_index + 1)] | string lower)
|
2020-10-24 01:07:41 +03:00
|
|
|
|
2021-05-12 23:13:51 +03:00
|
|
|
set -l distro_icons \
|
2021-03-22 08:25:50 +03:00
|
|
|
alpine \
|
|
|
|
aosc \
|
|
|
|
arch \
|
|
|
|
centos \
|
|
|
|
coreos \
|
|
|
|
debian \
|
|
|
|
devuan \
|
|
|
|
elementary \
|
|
|
|
fedora \
|
|
|
|
gentoo \
|
|
|
|
mageia \
|
|
|
|
manjaro \
|
|
|
|
mint \
|
|
|
|
nixos \
|
|
|
|
opensuse \
|
|
|
|
raspbian \
|
|
|
|
sabayon \
|
|
|
|
slackware \
|
|
|
|
tumbleweed \
|
|
|
|
ubuntu
|
|
|
|
|
2021-05-12 23:13:51 +03:00
|
|
|
set -l distro_index (contains --index $value $distro_icons) || return
|
2021-09-08 20:54:31 +03:00
|
|
|
echo -ns $distro_icons[(math $distro_index + 1)]
|
2020-07-30 03:30:32 +03:00
|
|
|
end
|