From f30557feacc28b58728c29dbc121d8985a4b2472 Mon Sep 17 00:00:00 2001 From: "Wu, Zhenyu" Date: Fri, 8 Nov 2024 17:41:13 +0800 Subject: [PATCH] add many OS icons --- assets/json/platform.json | 31 ++++++++++-- autoload/nerdfont/platform.vim | 90 +++++++++++++++++++++++++++++----- 2 files changed, 104 insertions(+), 17 deletions(-) diff --git a/assets/json/platform.json b/assets/json/platform.json index 10248ee..7b69e90 100644 --- a/assets/json/platform.json +++ b/assets/json/platform.json @@ -1,13 +1,36 @@ { - "android": "", + "alpine": "", + "amzn": "", + "android": "", + "aosc": "", "arch": "", + "artix": "", "centos": "", + "coreos": "", "debian": "", + "devuan": "", "docker": "", + "elementary": "", + "endeavouros": "", + "fedora": "", + "freebsd": "", "gentoo": "", - "linux": "", - "macos": "", + "guix": "", + "kali": "", + "linux": "", + "macos": "", + "mageia": "", + "manjaro": "", + "mint": "", "nixos": "", - "ubuntu": "", + "opensuse": "", + "raspbian": "", + "rhel": "", + "rocky": "", + "sabayon": "", + "slackware": "", + "sunos": "", + "ubuntu": "", + "void": "", "windows": "" } diff --git a/autoload/nerdfont/platform.vim b/autoload/nerdfont/platform.vim index 03f48b5..8bbd04b 100644 --- a/autoload/nerdfont/platform.vim +++ b/autoload/nerdfont/platform.vim @@ -6,6 +6,9 @@ function! nerdfont#platform#find(...) abort return get(s:m, n, '') endfunction +"" +" https://github.com/romkatv/powerlevel10k/blob/master/internal/wizard.zsh +" refer `os_icon_name()` function! s:find_platform() abort if exists('s:platform') return s:platform @@ -18,33 +21,94 @@ function! s:find_platform() abort let s:platform = 'macos' return s:platform endif + if has('sun') + let s:platform = 'sunos' + return s:platform + endif + if has('bsd') + let s:platform = 'freebsd' + return s:platform + endif " https://wiki.termux.com/wiki/Differences_from_Linux if $PREFIX ==# '/data/data/com.termux/files/usr' let s:platform = 'android' return s:platform endif + if filereadable('/etc/artix-release') + let s:platform = 'artix' + return s:platform + endif let s:platform = s:find_distro() return s:platform endfunction function! s:find_distro() abort - if executable('lsb_release') - let result = system('lsb_release -i') - if result =~# 'Arch' + if filereadable('/etc/os-release') + let result = '' + for line in readfile('/etc/os-release') + if line ==# 'ID=' + let result = substitute(line, '^ID=', '', '') + break + endif + endfor + if result =~# 'arch' return 'arch' - elseif result =~# 'NixOS' - return 'nixos' - elseif result =~# 'Gentoo' - return 'gentoo' - elseif result =~# 'Ubuntu' + elseif result =~# 'debian' + return 'debian' + elseif result =~# 'raspbian' + return 'raspbian' + elseif result =~# 'ubuntu' return 'ubuntu' - elseif result =~# 'Cent' + elseif result =~# 'elementary' + return 'elementary' + elseif result =~# 'fedora' + return 'fedora' + elseif result =~# 'coreos' + return 'coreos' + elseif result =~# 'kali' + return 'kali' + elseif result =~# 'gentoo' + return 'gentoo' + elseif result =~# 'mageia' + return 'mageia' + elseif result =~# 'centos' return 'centos' - elseif result =~# 'Debian' - return 'debian' - elseif result =~# 'Dock' + elseif result =~# 'opensuse' + return 'opensuse' + elseif result =~# 'tumbleweed' + return 'opensuse' + elseif result =~# 'sabayon' + return 'sabayon' + elseif result =~# 'slackware' + return 'slackware' + elseif result =~# 'linuxmint' + return 'mint' + elseif result =~# 'alpine' + return 'alpine' + elseif result =~# 'aosc' + return 'aosc' + elseif result =~# 'nixos' + return 'nixos' + elseif result =~# 'devuan' + return 'devuan' + elseif result =~# 'manjaro' + return 'manjaro' + elseif result =~# 'void' + return 'void' + elseif result =~# 'artix' + return 'artix' + elseif result =~# 'rhel' + return 'rhel' + elseif result =~# 'amzn' + return 'amzn' + elseif result =~# 'endeavouros' + return 'endeavouros' + elseif result =~# 'rocky' + return 'rocky' + elseif result =~# 'guix' + return 'guix' + elseif result =~# 'dock' return 'docker' - endif endif return 'linux' endfunction