Skip to content

Instantly share code, notes, and snippets.

#!/bin/zsh -f
# Purpose: Show the number of mounted devices (not including boot drive)
# Intended to be used with TextBar - http://www.richsomerfield.com/apps/
COUNT=`/sbin/mount | /usr/bin/egrep -v '^(devfs|map) ' | /usr/bin/wc -l | /usr/bin/tr -dc '[0-9]'`
# We don't want to count the boot drive, so subtract 1
COUNT=$(($COUNT - 1))
if [ "$COUNT" = "0" ]
#!/bin/zsh -f
# Purpose: This will show a MacBook’s current battery charge
# Intended to be used with TextBar - http://www.richsomerfield.com/apps/
/usr/sbin/ioreg -n AppleSmartBattery -r |\
awk '$1~/Capacity/{c[$1]=$3} END{OFMT="%.2f%%"; max=c["\"MaxCapacity\""]; print (max>0? 100*c["\"CurrentCapacity\""]/max: "?")}'
#
@tjluoma
tjluoma / textbar-ssid.sh
Created April 20, 2015 15:25
Show a Mac’s current SSID (Wi-Fi network)
#!/bin/zsh -f
# Purpose: Show the SSID (name of currently connected Wi-Fi network)
# Intended to be used with TextBar - http://www.richsomerfield.com/apps/
if [ ! -x '/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport' ]
then
echo "airport command not found"
exit 0
fi
@tjluoma
tjluoma / imsg.sh
Last active August 29, 2015 14:15
I use this script to send myself iMessages from my server at www.MacMiniColo.net when I need to know something (i.e. backup completed, diskspace getting low, etc). I got the idea from http://www.tenshu.net/2015/02/send-imessage-and-sms-with-applescript.html
#!/bin/zsh -f
### Change this to be your iMessage email account
MY_IMESSAGE='[email protected]'
### You should not need to change anything else
### I suggest saving this to /usr/local/bin/imsg.sh
### then `chmod 755 /usr/local/bin/imsg.sh`
###################################################################################################
# This is the name of the script without the path or the extension, so 'imsg' if you
#!/bin/bash
# Encode a WAV to a finalized podcast MP3 with metadata, in the current directory
# Requires lame
# With Homebrew on Mac OS X: brew install lame
# Usage:
# Call the script with three arguments:
# -t or --title followed by the title of the episode in quotes
# -s or --summary followed by the iTunes Summary for the episode, in quotes
@tjluoma
tjluoma / IgnitionAtWork.sh
Last active August 29, 2015 14:15
Example shell script to be used with IFTTT and launchd
#!/bin/zsh -f
# Important! DIR _must_ be the same as whatever directory you used
# for `QueueDirectories` in the `com.tjluoma.ignitiononoroffatwork.plist`
DIR="/Users/jsmyth/Dropbox/IFTTT/Automatic/IgnitionOnOrOffAtWork/"
# if the directory does not exist, exit
cd "$DIR" || exit 0
# get rid of this file, which will cause `launchd` to keep triggering
@tjluoma
tjluoma / com.tjluoma.IgnitionAtWork.plist
Last active December 21, 2016 08:51
Save this to ~/Library/LaunchAgents/com.tjluoma.ignitiononoroffatwork.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.tjluoma.IgnitionAtWork</string>
<key>Program</key>
<string>/usr/local/bin/IgnitionAtWork.sh</string>
<key>QueueDirectories</key>
<array>
@tjluoma
tjluoma / osxcombo.sh
Created February 9, 2015 20:51
Download and install the OS X combo updater
#!/bin/zsh
# Purpose: Download and install Mac OS X’s combo updater
#
# From: Tj Luo.ma
# Mail: luomat at gmail dot com
# Web: http://RhymesWithDiploma.com
# Date: 2014-05-15
# This is the only thing you _have_ to change
URL='http://support.apple.com/downloads/DL1786/en_US/OSXUpdCombo10.10.2.dmg'
@tjluoma
tjluoma / ftpd.sh
Created February 9, 2015 20:34
Easily turn FTPD on or off, or just see the status of it
#!/bin/zsh
#
# Author: Timothy J. Luoma
# Email: luomat at gmail dot com
# Date: 2014-05-08
#
# Purpose: enable / disable ftpd on OS X Lion (or later)
#
# URL: https://github.com/tjluoma/ftpd/
#
@tjluoma
tjluoma / sync.com.tjluoma.bittorrentsync.plist
Created February 9, 2015 05:28
launchd plist to launch BitTorrent Sync and keep it running, even if it crashes
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<dict>
<key>Crashed</key>
<true/>
<key>SuccessfulExit</key>
<false/>