Add support for lsb-release in detect_os (fixes #24)

This commit is contained in:
Ilan Cosman 2020-09-11 16:47:27 -07:00
parent 187846c7d7
commit 318bfeca54
5 changed files with 9 additions and 11 deletions

View File

@ -5,9 +5,9 @@ function _tide_detect_os
case freebsd openbsd dragonfly case freebsd openbsd dragonfly
set -g _tide_os_icon set -g _tide_os_icon
case linux case linux
if _tide_detect_os_linux_cases (_tide_detect_os_extract_os_release_info ID) if _tide_detect_os_linux_cases (_tide_detect_os_get_info /etc/os-release ID)
else if test "$tide_os_use_nearest" = 'true' && else if _tide_detect_os_linux_cases (_tide_detect_os_get_info /etc/os-release ID_LIKE)
_tide_detect_os_linux_cases (_tide_detect_os_extract_os_release_info ID_LIKE) else if _tide_detect_os_linux_cases (_tide_detect_os_get_info /etc/lsb-release DISTRIB_ID)
else else
set -g _tide_os_icon set -g _tide_os_icon
end end
@ -50,9 +50,11 @@ function _tide_detect_os_linux_cases -a name
return 0 # If we didn't run into the catch case '*', then return succesfull return 0 # If we didn't run into the catch case '*', then return succesfull
end end
function _tide_detect_os_extract_os_release_info -a key function _tide_detect_os_get_info -a file key
set -l splitOsRelease (cat /etc/os-release | string split '=') if test -e $file
set -l splitOsRelease (cat $file | string split '=')
set -l value $splitOsRelease[(math (contains --index $key $splitOsRelease)+1)] set -l value $splitOsRelease[(math (contains --index $key $splitOsRelease)+1)]
string trim --chars='"' $value | string lower string trim --chars='"' $value | string lower
end
end end

View File

@ -42,7 +42,6 @@ tide_nvm_default_node
tide_nvm_icon '⬢' tide_nvm_icon '⬢'
tide_os_bg_color 444444 tide_os_bg_color 444444
tide_os_color EEEEEE tide_os_color EEEEEE
tide_os_use_nearest true
tide_print_newline_before_prompt 'true' tide_print_newline_before_prompt 'true'
tide_prompt_char_bg_color normal tide_prompt_char_bg_color normal
tide_prompt_char_failure_color FF0000 tide_prompt_char_failure_color FF0000

View File

@ -42,7 +42,6 @@ tide_nvm_default_node
tide_nvm_icon '⬢' tide_nvm_icon '⬢'
tide_os_bg_color normal tide_os_bg_color normal
tide_os_color normal tide_os_color normal
tide_os_use_nearest true
tide_print_newline_before_prompt 'true' tide_print_newline_before_prompt 'true'
tide_prompt_char_bg_color normal tide_prompt_char_bg_color normal
tide_prompt_char_failure_color FF0000 tide_prompt_char_failure_color FF0000

View File

@ -42,7 +42,6 @@ tide_nvm_default_node
tide_nvm_icon '⬢' tide_nvm_icon '⬢'
tide_os_bg_color normal tide_os_bg_color normal
tide_os_color normal tide_os_color normal
tide_os_use_nearest true
tide_print_newline_before_prompt 'true' tide_print_newline_before_prompt 'true'
tide_prompt_char_bg_color normal tide_prompt_char_bg_color normal
tide_prompt_char_failure_color red tide_prompt_char_failure_color red

View File

@ -42,7 +42,6 @@ tide_nvm_default_node
tide_nvm_icon '⬢' tide_nvm_icon '⬢'
tide_os_bg_color CED7CF tide_os_bg_color CED7CF
tide_os_color 080808 tide_os_color 080808
tide_os_use_nearest true
tide_print_newline_before_prompt 'true' tide_print_newline_before_prompt 'true'
tide_prompt_char_bg_color normal tide_prompt_char_bg_color normal
tide_prompt_char_failure_color FF0000 tide_prompt_char_failure_color FF0000