Skip to content

Instantly share code, notes, and snippets.

@narate
Last active March 16, 2019 16:34
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save narate/c4c6d2e23b1dbb1e95c8 to your computer and use it in GitHub Desktop.
Save narate/c4c6d2e23b1dbb1e95c8 to your computer and use it in GitHub Desktop.
My archey OS X script. I'm not sure where this code came from. I install it via brew and then I edit via $ vim $(which archey)
#!/bin/bash
# System Variables
user=$(whoami)
hostname=$(hostname | sed 's/.local//g')
distro="OS X $(sw_vers -productVersion)"
kernel=$(uname)
uptime=$(uptime | sed 's/.*up \([^,]*\), .*/\1/')
shell="$SHELL"
terminal="$TERM"
cpu=$(sysctl -n machdep.cpu.brand_string)
packagehandler=""
# removes (R) and (TM) from the CPU name so it fits in a standard 80 window
cpu=$(echo "$cpu" | awk '$1=$1' | sed 's/([A-Z]\{1,2\})//g')
mem=$(sysctl -n hw.memsize)
ram="$((mem/1073741824)) GB"
disk=`df | head -2 | tail -1 | awk '{print $5}'`
disk_avail=`df -h | head -2 | tail -1 | awk '{print $4}'`
# Colors Variables
red="1"
green="2"
yellow="3"
blue="4"
purple="5"
lightblue="6"
grey="7"
textColor=$(tput setaf $lightblue)
normal=$(tput sgr0)
# Add a -c option to enable classic color logo
if [[ $1 == "-c" ]] || [[ $1 == "--color" ]] || [[ $2 == "-c" ]] || [[ $2 == "--color" ]]; then
GR='\033[00;32m'
YE='\033[00;33m'
LR='\033[01;31m'
RE='\033[00;31m'
PU='\033[00;35m'
CY='\033[00;36m'
BL='\033[00;34m'
fi
# Add a -m command to switch to macports or default to brew
if [[ $1 == "-m" ]] || [[ $1 == "--macports" ]] || [[ $2 == "-m" ]] || [[ $2 == "--macports" ]]
then
packagehandler="`port installed | wc -l | awk '{print $1 }'`"
else
packagehandler="`brew list -l | wc -l | awk '{print $1 }'`"
fi
userText="${textColor}User:${normal}"
hostnameText="${textColor}Hostname:${normal}"
distroText="${textColor}Distro:${normal}"
kernelText="${textColor}Kernel:${normal}"
uptimeText="${textColor}Uptime:${normal}"
shellText="${textColor}Shell:${normal}"
terminalText="${textColor}Terminal:${normal}"
packagehandlerText="${textColor}Packages:${normal}"
cpuText="${textColor}CPU:${normal}"
memoryText="${textColor}Memory:${normal}"
diskText="${textColor}Disk Used:${normal}"
availText="${textColor}Disk Available:${normal}"
echo -e "
${GR} ,
${GR} ,##;
${GR} ### $userText $user
${GR} ;#' $hostnameText $hostname
${GR} ,#####;, ,;#####;, $distroText $distro
${YE} ####################' $kernelText $kernel
${YE} ####################' $uptimeText $uptime
${RE} #################### $shellText $shell
${RE} #################### $terminalText $terminal
${RE} #####################, $packagehandlerText $packagehandler
${PU} ###################### $cpuText $cpu
${PU} ####################' $memoryText $ram
${BL} ################' $diskText $disk
${BL} '####''''####' $availText $disk_avail
${normal}
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment