tide/functions/_tide_detect_os.fish

54 lines
1.7 KiB
Fish
Raw Normal View History

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-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case freebsd openbsd dragonfly
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
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 ||
set -gx _tide_os_icon
2020-07-27 09:07:34 +03:00
case '*'
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon '?'
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
set -l splitFile (cat $file 2>/dev/null | string split '=') || return
2021-02-06 19:18:43 +03:00
set -l keyIndex (contains --index $key $splitFile) || return
set -l value $splitFile[(math $keyIndex + 1)]
2021-02-06 19:18:43 +03:00
switch (string trim --chars='"' $value | string lower)
2020-07-30 03:30:32 +03:00
case alpine
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case arch
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case centos
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case debian
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case elementary
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case fedora
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case gentoo
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case linuxmint
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case manjaro
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case nixos
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case opensuse tumbleweed
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case raspbian
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
case ubuntu
2020-11-24 01:56:52 +03:00
set -gx _tide_os_icon
2020-07-30 03:30:32 +03:00
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