pfetch: Fix WSL. Closes #57
This commit is contained in:
parent
e74081fa46
commit
1713dc68a1
22
pfetch
22
pfetch
|
@ -195,8 +195,8 @@ get_os() {
|
||||||
#
|
#
|
||||||
# If the kernel version string ends in "-Microsoft",
|
# If the kernel version string ends in "-Microsoft",
|
||||||
# we're very likely running under Windows 10 in WSL1.
|
# we're very likely running under Windows 10 in WSL1.
|
||||||
[ "${kernel%%*-Microsoft}" ] ||
|
if [ "$WSLENV" ]; then
|
||||||
distro="$distro on Windows 10 [WSL1]"
|
distro="${distro}${WSLENV+ on Windows 10 [WSL2]}"
|
||||||
|
|
||||||
# Check to see if Linux is running in Windows 10 under
|
# Check to see if Linux is running in Windows 10 under
|
||||||
# WSL2 (Windows subsystem for Linux [version 2]) and
|
# WSL2 (Windows subsystem for Linux [version 2]) and
|
||||||
|
@ -205,7 +205,9 @@ get_os() {
|
||||||
# This checks to see if '$WSLENV' is defined. This
|
# This checks to see if '$WSLENV' is defined. This
|
||||||
# appends the Windows 10 string even if '$WSLENV' is
|
# appends the Windows 10 string even if '$WSLENV' is
|
||||||
# empty. We only need to check that is has been _exported_.
|
# empty. We only need to check that is has been _exported_.
|
||||||
distro="${distro}${WSLENV+ on Windows 10 [WSL2]}"
|
elif [ -z "${kernel%%*-Microsoft}" ]; then
|
||||||
|
distro="$distro on Windows 10 [WSL1]"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
Darwin*)
|
Darwin*)
|
||||||
|
@ -296,8 +298,8 @@ get_kernel() {
|
||||||
case $os in
|
case $os in
|
||||||
# Don't print kernel output on some systems as the
|
# Don't print kernel output on some systems as the
|
||||||
# OS name includes it.
|
# OS name includes it.
|
||||||
*BSD*|Haiku|Minix)
|
*BSD*|Haiku|Minix)
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
@ -426,7 +428,7 @@ get_uptime() {
|
||||||
|
|
||||||
# Split the pretty output into days or hours
|
# Split the pretty output into days or hours
|
||||||
# based on the uptime.
|
# based on the uptime.
|
||||||
case $t in
|
case $t in
|
||||||
*-*) d=${t%%-*} t=${t#*-} ;;
|
*-*) d=${t%%-*} t=${t#*-} ;;
|
||||||
*:*:*) h=${t%%:*} t=${t#*:} ;;
|
*:*:*) h=${t%%:*} t=${t#*:} ;;
|
||||||
esac
|
esac
|
||||||
|
@ -750,10 +752,10 @@ get_memory() {
|
||||||
# Example output: Memory: 160M max, 147M avail, .....
|
# Example output: Memory: 160M max, 147M avail, .....
|
||||||
while IFS=' :' read -r label mem_full _ mem_free _; do
|
while IFS=' :' read -r label mem_full _ mem_free _; do
|
||||||
case $label in
|
case $label in
|
||||||
Memory)
|
Memory)
|
||||||
mem_full=${mem_full%M}
|
mem_full=${mem_full%M}
|
||||||
mem_free=${mem_free%M}
|
mem_free=${mem_free%M}
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done <<-EOF
|
done <<-EOF
|
||||||
|
@ -913,7 +915,7 @@ get_palette() {
|
||||||
|
|
||||||
# Print the palette with a new-line before and afterwards.
|
# Print the palette with a new-line before and afterwards.
|
||||||
printf '\n' >&6
|
printf '\n' >&6
|
||||||
log "$palette
|
log "$palette
|
||||||
" " " >&6
|
" " " >&6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1454,7 +1456,7 @@ get_ascii() {
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
[ "$1" = --version ] && {
|
[ "$1" = --version ] && {
|
||||||
printf 'pfetch 0.7.0\n'
|
printf 'pfetch 0.7.0\n'
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user