2017-06-03 16:33:51 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# ufetch-macos - tiny system info for macos
|
|
|
|
|
|
|
|
## INFO
|
|
|
|
|
|
|
|
# user is already defined
|
2020-09-26 09:09:49 -05:00
|
|
|
host="$(hostname -s)"
|
2017-06-11 22:54:43 -05:00
|
|
|
os="$(sw_vers -productName) $(sw_vers -productVersion)"
|
|
|
|
kernel="$(uname -sr)"
|
2017-06-03 16:33:51 +01:00
|
|
|
uptime="$(uptime | awk -F, '{sub(".*up ",x,$1);print $1}' | sed -e 's/^[ \t]*//')"
|
2020-12-13 08:16:42 -06:00
|
|
|
shell="$(basename "${SHELL}")"
|
2019-02-13 18:03:13 -06:00
|
|
|
|
|
|
|
## PACKAGE MANAGER DETECTION
|
|
|
|
|
2022-12-05 13:26:23 -06:00
|
|
|
if [ -x "$(command -v nix-info)" ]; then
|
|
|
|
packages="$(ls -d -1 /nix/store/*/ | wc -l)"
|
|
|
|
elif [ -x "$(command -v pkgin)" ]; then
|
2017-06-11 22:54:43 -05:00
|
|
|
packages="$(pkgin list | wc -l)"
|
2018-07-18 20:19:43 -03:00
|
|
|
elif [ -x "$(command -v brew)" ]; then
|
2020-10-28 23:13:54 +00:00
|
|
|
brew_packages="$(brew list --formulae | wc -l)"
|
|
|
|
cask_packages="$(brew list --cask 2> /dev/null | wc -l)"
|
2017-06-11 22:54:43 -05:00
|
|
|
packages="$(( ${brew_packages} + ${cask_packages} ))"
|
2018-07-18 20:19:43 -03:00
|
|
|
elif [ -x "$(command -v port)" ]; then
|
2017-06-11 22:54:43 -05:00
|
|
|
packages="$(port installed | wc -l)"
|
|
|
|
else
|
2019-02-13 18:03:13 -06:00
|
|
|
packages='unknown'
|
2017-06-11 22:54:43 -05:00
|
|
|
fi
|
2019-02-13 18:03:13 -06:00
|
|
|
|
2020-12-13 08:16:42 -06:00
|
|
|
packages="$(echo "${packages}" | sed -e 's/^[ /t]*//')"
|
2019-02-13 18:03:13 -06:00
|
|
|
|
|
|
|
## UI DETECTION
|
|
|
|
|
|
|
|
if [ -n "${DE}" ]; then
|
|
|
|
ui="${DE}"
|
|
|
|
uitype='DE'
|
|
|
|
elif [ -n "${WM}" ]; then
|
|
|
|
ui="${WM}"
|
|
|
|
uitype='WM'
|
|
|
|
else
|
|
|
|
ui='Aqua'
|
|
|
|
uitype='UI'
|
2017-06-11 22:54:43 -05:00
|
|
|
fi
|
2020-12-13 08:16:42 -06:00
|
|
|
|
|
|
|
ui="$(basename "${ui}")"
|
2017-06-03 16:33:51 +01:00
|
|
|
|
|
|
|
## DEFINE COLORS
|
|
|
|
|
|
|
|
# probably don't change these
|
2018-07-18 20:19:43 -03:00
|
|
|
if [ -x "$(command -v tput)" ]; then
|
2022-12-05 14:12:10 -06:00
|
|
|
bold="$(tput bold 2> /dev/null)"
|
|
|
|
black="$(tput setaf 0 2> /dev/null)"
|
|
|
|
red="$(tput setaf 1 2> /dev/null)"
|
|
|
|
green="$(tput setaf 2 2> /dev/null)"
|
|
|
|
yellow="$(tput setaf 3 2> /dev/null)"
|
|
|
|
blue="$(tput setaf 4 2> /dev/null)"
|
|
|
|
magenta="$(tput setaf 5 2> /dev/null)"
|
|
|
|
cyan="$(tput setaf 6 2> /dev/null)"
|
|
|
|
white="$(tput setaf 7 2> /dev/null)"
|
|
|
|
reset="$(tput sgr0 2> /dev/null)"
|
2018-07-18 20:19:43 -03:00
|
|
|
fi
|
2017-06-03 16:33:51 +01:00
|
|
|
|
|
|
|
# you can change these
|
2019-01-14 15:47:41 +13:00
|
|
|
lc="${reset}${bold}" # labels
|
|
|
|
nc="${reset}${bold}" # user and hostname
|
|
|
|
ic="${reset}" # info
|
|
|
|
c0="${reset}" # first color
|
2017-06-03 16:33:51 +01:00
|
|
|
|
|
|
|
## OUTPUT
|
|
|
|
|
|
|
|
cat <<EOF
|
2019-02-13 18:03:13 -06:00
|
|
|
${c0} _${reset}
|
2018-03-24 23:10:28 -05:00
|
|
|
${c0} (/ ${nc}${USER}${ic}@${nc}${host}${reset}
|
|
|
|
${c0} .---__--. ${lc}OS: ${ic}${os}${reset}
|
|
|
|
${c0} / \ ${lc}KERNEL: ${ic}${kernel}${reset}
|
|
|
|
${c0} | / ${lc}UPTIME: ${ic}${uptime}${reset}
|
|
|
|
${c0} | \\_ ${lc}PACKAGES: ${ic}${packages}${reset}
|
|
|
|
${c0} \ / ${lc}SHELL: ${ic}${shell}${reset}
|
2019-02-13 18:03:13 -06:00
|
|
|
${c0} \`._.-._.\` ${lc}${uitype}: ${ic}${ui}${reset}
|
2017-06-03 16:33:51 +01:00
|
|
|
|
|
|
|
EOF
|