New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OS name and version #724
Comments
That is going to be the trick. For the Portability is not likely without a bunch of testing and work put in. Might be easiest to just do |
Here is how Powerlevel10k is doing it in at most 3 subshell calls (MIT licensed): _p9k_uname="$(uname)"
[[ $_p9k_uname == Linux ]] && _p9k_uname_o="$(uname -o 2>/dev/null)"
_p9k_uname_m="$(uname -m)"
if [[ $_p9k_uname == Linux && $_p9k_uname_o == Android ]]; then
_p9k_set_os Android ANDROID_ICON
else
case $_p9k_uname in
SunOS) _p9k_set_os Solaris SUNOS_ICON;;
Darwin) _p9k_set_os OSX APPLE_ICON;;
CYGWIN*|MSYS*|MINGW*) _p9k_set_os Windows WINDOWS_ICON;;
FreeBSD|OpenBSD|DragonFly) _p9k_set_os BSD FREEBSD_ICON;;
Linux)
_p9k_os='Linux'
local os_release_id
if [[ -r /etc/os-release ]]; then
local lines=(${(f)"$(</etc/os-release)"})
lines=(${(@M)lines:#ID=*})
(( $#lines == 1 )) && os_release_id=${lines[1]#ID=}
elif [[ -e /etc/artix-release ]]; then
os_release_id=artix
fi
case $os_release_id in
*arch*) _p9k_set_os Linux LINUX_ARCH_ICON;;
*debian*) _p9k_set_os Linux LINUX_DEBIAN_ICON;;
*raspbian*) _p9k_set_os Linux LINUX_RASPBIAN_ICON;;
*ubuntu*) _p9k_set_os Linux LINUX_UBUNTU_ICON;;
*elementary*) _p9k_set_os Linux LINUX_ELEMENTARY_ICON;;
*fedora*) _p9k_set_os Linux LINUX_FEDORA_ICON;;
*coreos*) _p9k_set_os Linux LINUX_COREOS_ICON;;
*gentoo*) _p9k_set_os Linux LINUX_GENTOO_ICON;;
*mageia*) _p9k_set_os Linux LINUX_MAGEIA_ICON;;
*centos*) _p9k_set_os Linux LINUX_CENTOS_ICON;;
*opensuse*|*tumbleweed*) _p9k_set_os Linux LINUX_OPENSUSE_ICON;;
*sabayon*) _p9k_set_os Linux LINUX_SABAYON_ICON;;
*slackware*) _p9k_set_os Linux LINUX_SLACKWARE_ICON;;
*linuxmint*) _p9k_set_os Linux LINUX_MINT_ICON;;
*alpine*) _p9k_set_os Linux LINUX_ALPINE_ICON;;
*aosc*) _p9k_set_os Linux LINUX_AOSC_ICON;;
*nixos*) _p9k_set_os Linux LINUX_NIXOS_ICON;;
*devuan*) _p9k_set_os Linux LINUX_DEVUAN_ICON;;
*manjaro*) _p9k_set_os Linux LINUX_MANJARO_ICON;;
*void*) _p9k_set_os Linux LINUX_VOID_ICON;;
*artix*) _p9k_set_os Linux LINUX_ARTIX_ICON;;
*rhel*) _p9k_set_os Linux LINUX_RHEL_ICON;;
amzn) _p9k_set_os Linux LINUX_AMZN_ICON;;
*) _p9k_set_os Linux LINUX_ICON;;
esac
;;
esac
fi |
- Implements #724 - Display arch, family, kernel, distrib, version codename. - As a dev env item. - With hash-colored items. - Adds the `_lp_substitute` utility function.
- Implements #724 - Display arch, family, kernel, distrib, version codename. - As a dev env item. - With hash-colored items. - Adds the `_lp_substitute` utility function.
- Implements #724 - Display arch, family, kernel, distrib, version codename. - As a dev env item. - With hash-colored items. - Adds the `_lp_substitute` utility function. Co-authored-by: Mark Vander Stel <mvndrstl@gmail.com>
Display the OS name and version.
Description
Display somewhere the operating system name, optionally along with its version.
Probably use
lsb_release
.Not sure this can be done in a portable way, especially for Linux.
The text was updated successfully, but these errors were encountered: