Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # ==USER==
- user=$(whoami)
- # ==HOSTNAME==
- hostname=$(HOSTNAME | sed 's/.local//g')
- # if hostname is 35 characters, truncates to make it fit on std. 80 window
- if [ ${#HOSTNAME} -gt 35 ]
- then
- hostname=${HOSTNAME:0:35}
- fi
- # ==MODEL==
- model=$(system_profiler SPHardwareDataType -detailLevel mini | awk '/Model Identifier/ { print $3 }')
- # ==GRAPHICS==
- graphics=$(system_profiler SPDisplaysDataType |
- awk '/Model/{for (i=1; i<=NF-2; i++) $i = $(i+2); NF-=2; print}' | paste -sd "/" -)
- graphicsnoBrand=$(system_profiler SPDisplaysDataType |
- awk '/Model/{for (i=1; i<=NF-3; i++) $i = $(i+3); NF-=3; print}' | paste -sd "/" -)
- # Use system_profiler to find graphics cards, then awk to find 'Model'
- # Output of this step is lines such as this:
- # Chipset Model: Intel HD Graphics
- # Chipset Model: NVIDIA GeForce GT 330M
- # Use awk with a loop to print the arguments after Model: to end of line
- # Use paste to join multiple lines together with a slash if necessary.
- # Sample output:
- # graphics: Intel HD Graphics/NVIDIA GeForce GT 330M
- # graphicsnoBrand: HD Graphics/GeForce GT 330M
- # ==VERSION==
- versionNumber=$(sw_vers -productVersion) # Finds version number
- versionShort=${versionNumber:0:4} # Cut sting to 1 decimal place for calculation
- #music=$(./nowplaying)
- music="test"
- case $versionShort in
- 10.9)
- versionString="Mavericks"
- ;;
- 10.8)
- versionString="Mountian Lion"
- ;;
- 10.7)
- versionString="Lion"
- ;;
- 10.6)
- versionString="Snow Leopard"
- ;;
- 10.5)
- versionString="Leopard"
- ;;
- 10.4)
- versionString="Tiger"
- ;;
- 10.3)
- versionString="Panther"
- ;;
- 10.2)
- versionString="Jaguar"
- ;;
- 10.1)
- versionString="el Capitan"
- ;;
- 10.0)
- versionString="Cheetah"
- ;;
- esac
- version="$versionString"
- # ==KERNEL==
- kernel="XNU"
- # ==UPTIME==
- uptime=$(uptime | sed 's/.*up \([^,]*\), .*/\1/')
- # ==SHELL==
- shell="$SHELL"
- wm="Quartz"
- # ==TERMINAL==
- terminal="$TERM"
- # ==PACKAGE MANAGER==
- # check if brew or macports is installed, then total there packages and set packagehandler
- if [ -e /usr/local/bin/brew ]
- then
- brewpackages=$(brew list -l | tail -n +2 | wc -l)
- packagehandler=$brewpackages
- elif [ -f /opt/local/bin/port ] #don't think this is the right directory, need to check later.
- then
- macportpackages="`port installed | wc -l | awk '{print $1 }'`"
- packagehandler=$macportpackages
- fi
- # ==CPU==
- cpu=$(sysctl -n machdep.cpu.brand_string)
- # 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')
- # ==MEMORY==
- mem=$(sysctl -n hw.memsize)
- mem="$((mem/1000000000)) GB"
- # ==DISK==
- disk=`df -Hl | head -2 | tail -1`
- dpercent=`echo $disk | awk '{print $5}'`
- dfree=`echo $disk | awk '{print $4}'`
- dused=`echo $disk | awk '{print $3}'`
- dcapacity=`echo $disk | awk '{print $2}'`
- # Colors Variables
- red="1"
- green="2"
- yellow="3"
- blue="4"
- purple="5"
- lightblue="6"
- grey="7"
- textColor=$(tput setaf $red)
- normal=$(tput sgr0)
- 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'
- # While loops for script arguments
- while [ $# -gt 0 ]
- do
- case "$1" in
- -c|--color)
- 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'
- shift
- ;;
- -red)
- textColor=$(tput setaf $red)
- shift
- ;;
- -green)
- textColor=$(tput setaf $green)
- shift
- ;;
- -yellow)
- textColor=$(tput setaf $yellow)
- shift
- ;;
- -blue)
- textColor=$(tput setaf $blue)
- shift
- ;;
- -purple)
- textColor=$(tput setaf $purple)
- shift
- ;;
- -grey)
- textColor=$(tput setaf $grey)
- shift
- ;;
- *)
- break
- ;;
- esac
- done
- userText="${textColor}Host${normal}"
- hostnameText="${textColor}Hostname:${normal}"
- modelText="${textColor}Model ${normal}"
- versionText="${textColor}OS${normal}"
- kernelText="${textColor}Kernel:${normal}"
- uptimeText="${textColor}Uptime${normal}"
- shellText="${BL}${textColor}Shell${normal}"
- terminalText="${textColor}Terminal:${normal}"
- packagehandlerText="${textColor}Packages:${normal}"
- cpuText="${textColor}CPU:${normal}"
- memoryText="${textColor}Memory:${normal}"
- graphicsText="${textColor}Graphics:$normal"
- diskText="${textColor}Disk${normal}"
- musicText="${textColor}Music${normal}"
- wmText="${textColor}WM${normal}"
- echo -e "
- ${GR} ▄▆█
- ${GR} ▗███▀
- ${GR} ███▀
- ${GR} ▂▂ ▗█▛ ▂▂▂
- ${GR} ▄██████▄▄▄▄██████▄
- ${GR} ▄████████████████████▖
- ${YE} ▟████████████████████▛▘ $userText $user@$(HOSTNAME | sed 's/.local//g')
- ${YE} ▟████████████████████▘ $versionText $version
- ${RE} ████████████████████▌ ${textColor}WM ${normal}$wm
- ${RE} ████████████████████▙ $uptimeText $uptime
- ${RE} ▐████████████████████▄ $diskText $dpercent
- ${RE} ██████████████████████▄ $modelText $model
- ${PU} ▝██████████████████████
- ${PU} ▀████████████████████▛
- ${BL} ▀█████████████████▀
- ${BL} ▝▀██▛▀▔ ▔▀▀██▀▀
- ${normal}
- "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement