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
|
2020-07-27 09:07:34 +03:00
|
|
|
set -g _tide_os_icon
|
2020-07-30 03:30:32 +03:00
|
|
|
case freebsd openbsd dragonfly
|
2020-07-27 09:07:34 +03:00
|
|
|
set -g _tide_os_icon
|
2020-07-30 03:30:32 +03:00
|
|
|
case linux
|
2020-09-23 23:48:55 +03:00
|
|
|
if _tide_detect_os_linux_cases /etc/os-release ID
|
|
|
|
else if _tide_detect_os_linux_cases /etc/os-release ID_LIKE
|
|
|
|
else if _tide_detect_os_linux_cases /etc/lsb-release DISTRIB_ID
|
2020-07-30 03:30:32 +03:00
|
|
|
else
|
|
|
|
set -g _tide_os_icon
|
2020-07-27 09:07:34 +03:00
|
|
|
end
|
|
|
|
case '*'
|
|
|
|
set -g _tide_os_icon '?'
|
|
|
|
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
|
2020-10-24 01:07:41 +03:00
|
|
|
if not test -f $file
|
|
|
|
return 1
|
|
|
|
end
|
|
|
|
|
2020-09-23 23:48:55 +03:00
|
|
|
set -l splitOsRelease (cat $file | string split '=')
|
|
|
|
set -l value $splitOsRelease[(math (contains --index $key $splitOsRelease)+1)]
|
|
|
|
set -l name (string trim --chars='"' $value | string lower)
|
|
|
|
|
2020-07-30 03:30:32 +03:00
|
|
|
switch $name
|
|
|
|
case alpine
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case arch
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case centos
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case debian
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case elementary
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case fedora
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case gentoo
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case linuxmint
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case manjaro
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case nixos
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case opensuse tumbleweed
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case raspbian
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case ubuntu
|
|
|
|
set -g _tide_os_icon
|
|
|
|
case '*'
|
|
|
|
return 1
|
|
|
|
end
|
2020-09-12 08:15:25 +03:00
|
|
|
return 0 # If we didn't run into the catch case '*' return succesfull
|
2020-07-30 03:30:32 +03:00
|
|
|
end
|