From 6f6129f0712fe36b9d0ffc7ef61e4c976b9c75bc Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Tue, 28 Mar 2023 09:44:46 -0700 Subject: [PATCH] [zsh] Use the darwin- system info functions in init_profile_darwin_say_hello --- zsh/func/init_profile_darwin_say_hello | 29 ++++++++++++++------------ 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/zsh/func/init_profile_darwin_say_hello b/zsh/func/init_profile_darwin_say_hello index b66074b..f3e3b5c 100644 --- a/zsh/func/init_profile_darwin_say_hello +++ b/zsh/func/init_profile_darwin_say_hello @@ -1,31 +1,34 @@ -#!/usr/bin/env zsh # Eryn Wells autoload -Uz binary_exists +autoload -Uz darwin-os-version +autoload -Uz darwin-os-build +autoload -Uz darwin-hardware-model -if binary_exists sw_vers && [[ -n "$HWMODEL" && -n "$OSVERSION" && -n "$OSBUILD" ]]; then - cat_program=cat +init_profile_darwin_say_hello() { + local cat_program=cat if binary_exists lolcat; then cat_program=lolcat fi local hello_message="It's `date +'%H:%M on %A, %B %d'`." - if [[ -n "$HWMODEL" ]]; then - hello_message+="\nThis machine is a $HWMODEL." + local hardware_model=`darwin-hardware-model` + if [[ -n "$hardware_model" ]]; then + hello_message+="\nThis machine is a $hardware_model." fi - if [[ -n "$OSVERSION" ]]; then - if [[ -n "$OSBUILD" ]]; then - hello_message+="\nYou're running macOS $OSVERSION ($OSBUILD)." + local os_version=`darwin-os-version` + if [[ -n "$os_version" ]]; then + local os_build=`darwin-os-build` + if [[ -n "$os_build" ]]; then + hello_message+="\nYou're running macOS $os_version ($os_build)." else - hello_message+="\nYou're running macOS $OSVERSION." + hello_message+="\nYou're running macOS $os_version." fi fi print "$hello_message\n" | $cat_program +} - return 0 -fi - -return 1 +init_profile_darwin_say_hello "$@"