Skip to content

Commit

Permalink
add many OS icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Nov 8, 2024
1 parent 4dec28b commit f30557f
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 17 deletions.
31 changes: 27 additions & 4 deletions assets/json/platform.json
Original file line number Diff line number Diff line change
@@ -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": ""
}
90 changes: 77 additions & 13 deletions autoload/nerdfont/platform.vim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f30557f

Please sign in to comment.