ufetch/ufetch-macos

66 lines
1.8 KiB
Text
Raw Normal View History

2017-06-03 16:33:51 +01:00
#!/bin/sh
#
# ufetch-macos - tiny system info for macos
## INFO
# user is already defined
2017-06-11 22:54:43 -05:00
host="$(hostname)"
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]*//')"
2017-06-11 22:54:43 -05:00
if command -v pkgin &> /dev/null; then
packages="$(pkgin list | wc -l)"
elif command -v brew &> /dev/null; then
brew_packages="$(brew list | wc -l)"
cask_packages="$(brew cask list 2> /dev/null | wc -l)"
packages="$(( ${brew_packages} + ${cask_packages} ))"
elif command -v port &> /dev/null; then
packages="$(port installed | wc -l)"
else
packages='no package manager'
fi
packages="$(echo ${packages} | sed -e 's/^[ /t]*//')"
2017-06-03 16:33:51 +01:00
shell="$(basename ${SHELL})"
2017-06-11 22:54:43 -05:00
if [ -z "${WM}" ]; then
WM='Quartz Compositor'
fi
2017-06-03 16:33:51 +01:00
## DEFINE COLORS
# probably don't change these
2018-03-24 14:01:24 -05:00
bold="$(tput bold)"
black="$(tput setaf 0)"
red="$(tput setaf 1)"
green="$(tput setaf 2)"
yellow="$(tput setaf 3)"
blue="$(tput setaf 4)"
magenta="$(tput setaf 5)"
cyan="$(tput setaf 6)"
white="$(tput setaf 7)"
reset="$(tput sgr0)"
2017-06-03 16:33:51 +01:00
# you can change these
2018-03-24 14:01:24 -05:00
lc="${reset}${bold}${blue}" # labels
nc="${reset}${bold}${blue}" # user and hostname
ic="${reset}${bold}${white}" # info
c0="${reset}${green}" # first color
c1="${reset}${yellow}" # second color
c2="${reset}${red}" # third color
c3="${reset}${magenta}" # fourth color
c4="${reset}${cyan}" # fifth color
2017-06-03 16:33:51 +01:00
## OUTPUT
cat <<EOF
2018-03-24 14:01:24 -05:00
${c0} .:' ${nc}${USER}${ic}@${nc}${host}${reset}
${c0} _ :'_ ${lc}OS: ${ic}${os}${reset}
${c1} .'\`_\`-'_\`\`. ${lc}KERNEL: ${ic}${kernel}${reset}
${c2} :________.-' ${lc}UPTIME: ${ic}${uptime}${reset}
${c2} :_______: ${lc}PACKAGES: ${ic}${packages}${reset}
${c3} :_______\`-; ${lc}SHELL: ${ic}${shell}${reset}
${c4} \`._.-._.' ${lc}WM: ${ic}${WM}${reset}
2017-06-03 16:33:51 +01:00
EOF