copy and paste this in the commands bar
The scripts will become more and more complicated
Time: date +"%l:%M:%S"
Day of the week: date +%A
Month: date +%B
AM/ PM: date +%p
Calendar: cal | sed -E '1,$'"s/ ($(date +%e))( |$)/ $(echo '\033[1;31m')\1$(echo '\033[0m')\2/"
Calendar long: #!/usr/bin/env ruby
#
# Author: Robert Jorgenson
# Author email: rjorgenson@gmail.com
require 'Date'
ABBR_DAYNAMES = {0, 'Su', 1, 'Mo', 2, 'Tu', 3, 'We', 4, 'Th', 5, 'Fr', 6, 'Sa'}
def build_month(year,month)
if month < 10 then
mnt = "0#{month}/#{year}"
else
mnt = "#{month}/#{year}"
end
return mnt
end
def days_in_month(year, month)
return (Date.new(year, 12, 31) << (12 - month)).day
end
def day_in_month(year, month, day)
return Date.new(year, month, day).wday
end
def build_day_array(year, month)
day_array = Array.new
for d in (1..days_in_month(year, month))
day_array[d] = ABBR_DAYNAMES[day_in_month(year, month, d)]
end
day_array.shift
return day_array * " "
end
def build_separator(year, month)
color = "\e[32m" #green
#color = "\e[31m" #uncomment for red
separator_string = "==" # change this to change separator, best if 2 characters wide
close = "\e[0m" # don't change this
separator = Array.new
for d in (1..days_in_month(year, month))
if year == Time.now.year && month == Time.now.month && d == Time.now.day then
separator[d] = "#{separator_string}"
else
separator[d] = "#{separator_string}"
end
end
separator.shift
return separator * " "
end
def build_date_array(year, month)
color = "\e[37m" #green
close = "\e[0m" # don't change this
date_array = Array.new
for d in (1..days_in_month(year, month))
date_array[d] = d
end
date_array.shift
date_array.each do |d|
if year == Time.now.year && month == Time.now.month && d == Time.now.day then
if d < 10 then
date_array[(d-1)] = "#{color}0#{d}#{close}"
else
date_array[(d-1)] = "#{color}#{d}#{close}"
end
else
if d < 10 then
date_array[(d-1)] = "0#{d}"
else
date_array[(d-1)] = "#{d}"
end
end
end
return date_array * " "
end
year = Time.now.year
month = Time.now.month
puts build_day_array(year, month)
#puts build_separator(year, month)
puts build_date_array(year, month)
Uptime (see what your computer is up to)
uptime | awk '{print "UPTIME : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/; NR; 5 {printf "CPU" $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}'
The scripts will become more and more complicated
Time: date +"%l:%M:%S"
Day of the week: date +%A
Month: date +%B
AM/ PM: date +%p
Calendar: cal | sed -E '1,$'"s/ ($(date +%e))( |$)/ $(echo '\033[1;31m')\1$(echo '\033[0m')\2/"
Calendar long: #!/usr/bin/env ruby
#
# Author: Robert Jorgenson
# Author email: rjorgenson@gmail.com
require 'Date'
ABBR_DAYNAMES = {0, 'Su', 1, 'Mo', 2, 'Tu', 3, 'We', 4, 'Th', 5, 'Fr', 6, 'Sa'}
def build_month(year,month)
if month < 10 then
mnt = "0#{month}/#{year}"
else
mnt = "#{month}/#{year}"
end
return mnt
end
def days_in_month(year, month)
return (Date.new(year, 12, 31) << (12 - month)).day
end
def day_in_month(year, month, day)
return Date.new(year, month, day).wday
end
def build_day_array(year, month)
day_array = Array.new
for d in (1..days_in_month(year, month))
day_array[d] = ABBR_DAYNAMES[day_in_month(year, month, d)]
end
day_array.shift
return day_array * " "
end
def build_separator(year, month)
color = "\e[32m" #green
#color = "\e[31m" #uncomment for red
separator_string = "==" # change this to change separator, best if 2 characters wide
close = "\e[0m" # don't change this
separator = Array.new
for d in (1..days_in_month(year, month))
if year == Time.now.year && month == Time.now.month && d == Time.now.day then
separator[d] = "#{separator_string}"
else
separator[d] = "#{separator_string}"
end
end
separator.shift
return separator * " "
end
def build_date_array(year, month)
color = "\e[37m" #green
close = "\e[0m" # don't change this
date_array = Array.new
for d in (1..days_in_month(year, month))
date_array[d] = d
end
date_array.shift
date_array.each do |d|
if year == Time.now.year && month == Time.now.month && d == Time.now.day then
if d < 10 then
date_array[(d-1)] = "#{color}0#{d}#{close}"
else
date_array[(d-1)] = "#{color}#{d}#{close}"
end
else
if d < 10 then
date_array[(d-1)] = "0#{d}"
else
date_array[(d-1)] = "#{d}"
end
end
end
return date_array * " "
end
year = Time.now.year
month = Time.now.month
puts build_day_array(year, month)
#puts build_separator(year, month)
puts build_date_array(year, month)
Uptime (see what your computer is up to)
uptime | awk '{print "UPTIME : " $3 " " $4 " " $5 " " }'; top -l 1 | awk '/PhysMem/ {print "RAM : " $8 " "}' ; top -l 2 | awk '/CPU usage/; NR; 5 {printf "CPU" $6, $7=":", $8, $9="user ", $10, $11="sys ", $12, $13}'
Ram used: Sorry if this didn't work at first (only copied half of it)
used_ram=`top -l 1 | awk '/PhysMem/ {print $8}' | sed "s/M//"`
free_ram=`top -l 1 | awk '/PhysMem/ {print $10}' | sed "s/M//"`
let total_ram=$used_ram+$free_ram
used_percent=$(echo "scale=2; $used_ram / $total_ram * 100" | bc)
used_percent=`echo $used_percent | cut -d . -f 1`
let count=5
echo "ram \c"
while [ $count -le $used_percent ]
do
if [ $used_percent -le 50 ]
then
echo "\033[1;32m|\c" # green
colour='\033[0;32m'
elif [ $used_percent -le 75 ]
then
echo "\033[1;33m|\c" # yellow
colour='\033[0;33m'
elif [ $used_percent -le 100 ]
then
echo "\033[1;31m|\c" # red
colour='\033[0;31m'
fi
let count=${count}+5
done
# Default output. Place a # (comment) sign at the start of the next "echo" line if wishing top use the Extended output.
echo $colour $used_percent%
# Extended output. Remove the # sign from the "echo" line below to use.
# echo $colour $used_percent% Used, ${free_ram}MB Free
Battery life (bars)
ioreg=`ioreg -w0 -l | grep "ExternalConnected\|CurrentCapacity\|MaxCapacity" | awk '{print $5}'`
ac_adapt=`echo $ioreg | awk '{print $1}'`
max_power=`echo $ioreg | awk '{print $2}'`
cur_power=`echo $ioreg | awk '{print $3}'`
bat_percent=`echo "scale=2;$cur_power / $max_power" | bc`
bat_percent=`echo "$bat_percent * 100" | bc | sed 's/\.00//'`
declare -i a=5
if [ $ac_adapt == "Yes" ]
then
echo "EXT \c"
else
echo "BAT \c"
fi
while [ $a -lt $bat_percent ]
do
echo "|\c"
a=`expr $a + 5`
done
echo "\033[1;31m|\033[0m\c"
while [ $a -lt 100 ]
do
echo "\033[1;30m|\033[0m\c"
used_ram=`top -l 1 | awk '/PhysMem/ {print $8}' | sed "s/M//"`
free_ram=`top -l 1 | awk '/PhysMem/ {print $10}' | sed "s/M//"`
let total_ram=$used_ram+$free_ram
used_percent=$(echo "scale=2; $used_ram / $total_ram * 100" | bc)
used_percent=`echo $used_percent | cut -d . -f 1`
let count=5
echo "ram \c"
while [ $count -le $used_percent ]
do
if [ $used_percent -le 50 ]
then
echo "\033[1;32m|\c" # green
colour='\033[0;32m'
elif [ $used_percent -le 75 ]
then
echo "\033[1;33m|\c" # yellow
colour='\033[0;33m'
elif [ $used_percent -le 100 ]
then
echo "\033[1;31m|\c" # red
colour='\033[0;31m'
fi
let count=${count}+5
done
# Default output. Place a # (comment) sign at the start of the next "echo" line if wishing top use the Extended output.
echo $colour $used_percent%
# Extended output. Remove the # sign from the "echo" line below to use.
# echo $colour $used_percent% Used, ${free_ram}MB Free
Battery life (bars)
ioreg=`ioreg -w0 -l | grep "ExternalConnected\|CurrentCapacity\|MaxCapacity" | awk '{print $5}'`
ac_adapt=`echo $ioreg | awk '{print $1}'`
max_power=`echo $ioreg | awk '{print $2}'`
cur_power=`echo $ioreg | awk '{print $3}'`
bat_percent=`echo "scale=2;$cur_power / $max_power" | bc`
bat_percent=`echo "$bat_percent * 100" | bc | sed 's/\.00//'`
declare -i a=5
if [ $ac_adapt == "Yes" ]
then
echo "EXT \c"
else
echo "BAT \c"
fi
while [ $a -lt $bat_percent ]
do
echo "|\c"
a=`expr $a + 5`
done
echo "\033[1;31m|\033[0m\c"
while [ $a -lt 100 ]
do
echo "\033[1;30m|\033[0m\c"
Load Average
top -n1 -l1 | grep "Load Avg" | sed 's/.*usage: //; s/ user.*//;'
top -n1 -l1 | grep "Load Avg" | sed 's/.*user, //; s/ sys.*//;'
top -n1 -l1 | grep "Load Avg" | sed 's/.*sys, //; s/ idle.*//;'
Good calendar red
cal | sed -E '1,$'"s/ ($(date +%e))( |$)/ $(echo '\033[1;31m')\1$(echo '\033[0m')\2/"
For the weather create an image screen with this url:
Then create a separate script with one of these:
Weather radar NY
curl --silent "http://www.weather.com/weather/map/USNY1265" | grep "mapImg" | sed 's/^.*src="//' | sed 's/".*$//' | xargs curl --silent -o /tmp/weather_map_satelite.jpg\
Weather Radar TX
curl --silent "http://www.weather.com/weather/map/USTX0617" | grep "mapImg" | sed 's/^.*src="//' | sed 's/".*$//' | xargs curl --silent -o /tmp/weather_map_satelite.jpg\
Weather radar MA
curl --silent "http://www.weather.com/weather/map/ USMA0102" | grep "mapImg" | sed 's/^.*src="//' | sed 's/".*$//' | xargs curl --silent -o /tmp/weather_map_satelite.jpg\
Weather Radar LA
curl --silent "http://www.weather.com/weather/map/ USCA0638
" | grep "mapImg" | sed 's/^.*src="//' | sed 's/".*$//' | xargs curl --silent -o /tmp/weather_map_satelite.jpg\
Weather Radar London
curl --silent "http://www.weather.com/weather/map/ UKXX0085
" | grep "mapImg" | sed 's/^.*src="//' | sed 's/".*$//' | xargs curl --silent -o /tmp/weather_map_satelite.jpg\
Weather Radar Rome
curl --silent "http://www.weather.com/weather/map/ ITXX0067
" | grep "mapImg" | sed 's/^.*src="//' | sed 's/".*$//' | xargs curl --silent -o /tmp/weather_map_satelite.jpg\
Weather Radar Istanbul
curl --silent "http://www.weather.com/weather/map/ TUXX0014
" | grep "mapImg" | sed 's/^.*src="//' | sed 's/".*$//' | xargs curl --silent -o /tmp/weather_map_satelite.jpg\
Weather Radar Philly
curl --silent "http://www.weather.com/weather/map/ USPA1276
" | grep "mapImg" | sed 's/^.*src="//' | sed 's/".*$//' | xargs curl --silent -o /tmp/weather_map_satelite.jpg\
Wifi
/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -I | awk -F: '/ SSID: / {print $2}' | sed -e 's/SSID: //' | sed -e 's/ //'
local IPs
echo "Local IPs";ifconfig | grep "inet" | grep -v 127.0.0.1 | grep -v inet6 | awk '{print $2}'
External IPs
echo External IP: `curl -s http://checkip.dyndns.org/ | sed 's/[a-zA-Z<>/ :]//g'`
CPU/ memory usage chart
ps -amcwwwxo "command %mem %cpu" | grep -v grep | head -19
load average
top -n1 -l1 | grep "Load Avg" | sed 's/.*sys, //; s/ idle.*//;'
KB/ second
EN0=`ifconfig en0 | grep 'status' | awk '{print $2}'`
EN1=`ifconfig en1 | grep 'status' | awk '{print $2}'`
if [ $EN0 == 'active' ] ; then
INTERFACE=en0
elif [ $EN1 == 'active' ] ; then
INTERFACE=en1
fi
SAMPLE_A=(`/usr/sbin/netstat -bI "$INTERFACE" | awk "/$INTERFACE/"'{print $7" "$10; exit}'`);
sleep 1;
SAMPLE_B=(`/usr/sbin/netstat -bI "$INTERFACE" | awk "/$INTERFACE/"'{print $7" "$10; exit}'`);
BANDWIDTH_USAGE=(`echo "2k ${SAMPLE_B[0]} ${SAMPLE_A[0]} - 1024 / p" "${SAMPLE_B[1]} ${SAMPLE_A[1]} - 1024 / p" | dc`);printf "In: \t%.2f Kb/sec\nOut: \t%.2f Kb/sec\n" ${BANDWIDTH_USAGE[0]} ${BANDWIDTH_USAGE[1]};
Memory
df -H -l
ITunes info
DATA=$(osascript -e 'tell application "System Events"
set myList to (name of every process)
end tell
if myList contains "iTunes" then
tell application "iTunes"
if player state is stopped then
set output to "Stopped"
else
set trackname to name of current track
set artistname to artist of current track
set albumname to album of current track
if player state is playing then
set output to trackname & " | " & artistname & " | " & albumname & "new_line" & "Playing on iTunes | "
else if player state is paused then
set output to trackname & " | " & artistname & " | " & albumname & "new_line" & "Paused | "
end if
end if
end tell
else
set output to "iTunes is not running"
end if')
echo $DATA | awk -F new_line '{print $1}'
echo $DATA | awk -F new_line '{print $2}'
Today in history
curl http://www.infoplease.com/rss/dayinhistory.rss | grep CDATA | sed -e 's/\(.*\[\)//' -e 's/\].*//'
Weather prediction
curl --silent "http://xml.weather.yahoo.com/forecastrss?p=10580&u=f" | grep -E '(High:)' | sed -e 's/<BR \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<br \/>//'
Date in numbers (xx-xx-xx)
date +%D