Here are some scripts I find useful. Most are generic Bash scripts, but a few are AppleScripts or call OS X programs such as Eudora or BBEdit.
In many cases, you'll need to make a few simple customizations on them, as explained below.
I install Bash scripts and command-line utilities in
/usr/local/bin/
. You can install
wherever you like, but some scripts call others, so if you choose a
different location you'll need to change the calling script. Also, I
find it helpful to add the installation directory to my path
,
using the shell customization script ~/.bash_profile
.
For example, to add /usr/local/bin/
,
add the following lines to your .bash_profile
file:
echo $PATH | grep -q -s "/usr/local/bin"
if [ $? -eq 1 ] ; then
PATH=$PATH:/usr/local/bin
export PATH
fi
Script | Description | Dependencies | Customization | |
---|---|---|---|---|
cwdiff.scpt | A BBEdit script (install into ~/Library/Application Support/BBEdit ) that runs OS X's excellent diff utility (part of the Developer Tools) or CodeWarrior's diff tool to show differences between an open document and an earlier version of that document. For Internet Drafts, which follow a naming convention where the last component of the name (before the .txt extension) is a version identifier, it runs a small Perl script to guess at the earlier file. For other files, it asks you to pick the file to compare against. In all cases you get to pick a different file, such as if you want to compare version 08 against version 06. Personally, I love BBEdit, but prefer OS X's diff tool, which has a very nice UI, and shows the specific words on a line that are different. |
Uses cwdiff and get_prev_id . |
May need to change location of dependencies if they are installed somewhere other than /usr/local/bin/ . |
|
get_prev_id | Guesses at the name of the previous version of a file | (none) | (none) | |
cwdiff | Command-line tool to run a diff tool to compare two files. The older file can be specified or it guesses based on the older file. Runs OS X's excellent FileMerge diff utility (part of the Developer Tools), CodeWarrior, or Perforce p4merge. | Uses get_prev_id . |
May need to change location of dependencies if they are installed somewhere other than /usr/local/bin/ . |
|
open_id | Opens an Internet Draft in your preferred editor. You only need to specify part of the file name; the script finds matching drafts and chooses the latest matching file. If it can't find any matches it uses get_id to download it. It optionally runs get_id in the background anyway to look for updates; if any are found it opens them. |
Uses get_id if no matching drafts are found or if requested. |
You may need to edit the directory where you keep Internet Drafts. The default is IETF/Internet_Drafts in your home directory. If you need to edit this, look for the string ID_DIR .
Uses May need to change location of dependencies if they are installed somewhere other than |
|
get_id | Fetches Internet Drafts which match a string. On MacOS, optionally sets the file type and creator of downloaded files to open using your preferred editor. Only downloads actual drafts; ignores stubs for expired or published documents. Only downloads files which don't already exist locally. Optionally sends email to let you know when new files have been downloaded, which is handy if you want to run it automatically, such as using cron or launchctl . |
Optionally runs Eudora or another mail program | You may need to edit the directory where you keep Internet Drafts. The default is IETF/Internet_Drafts in your home directory. If you need to edit this, look for the string ID_DIR .
If you want it to send you mail and you don't use Eudora, you'll need to edit the mail program. If you want to change the creator code optionally assigned on MacOS, look for |
|
list_id | Lists IDs that you have. You only need to specify part of the file name; the script finds matching drafts and chooses the latest matching file. It optionally runs get_id in the background anyway to look for updates; if any are found it opens them. |
Uses get_id if no matching drafts are found or if requested. |
You may need to edit the directory where you keep Internet Drafts. The default is IETF/Internet_Drafts in your home directory. If you need to edit this, look for the string ID_DIR .
Uses May need to change location of dependencies if they are installed somewhere other than |
|
get_rfc | Fetches one or more RFCs, the text RFC index, or the XML RFC citation library. On MacOS, optionally sets the file type and creator of downloaded RFCs to open using your preferred editor. | (none) | You may need to edit the directory where you keep RFCs. The default is IETF/RFCs in your home directory. If you need to edit this, look for the string RFC_DIR .
May need to edit the directory where your xml bibliography files live. The default is individual subdirectories under If you want to change the creator code optionally assigned on MacOS, look for |
|
open_rfc | Opens an RFC in your preferred editor. If the RFC doesn't exist locally, runs get_rfc to fetch it. |
Uses get_rfc |
You may need to edit the directory where you keep RFCs. The default is IETF/RFCs in your home directory. If you need to edit this, look for the string RFC_DIR .
Uses May need to change location of dependencies if they are installed somewhere other than |
|
get_id.plist | Put this in your ~/Library/LaunchAgents/ folder if you want to use OS X's LaunchDaemon to automatically run get_id . Edit this file to select which Internet Drafts to look for (such as by group name or area of interest) and how often to run. |
Runs get_id . |
Edit this file to select which Internet Drafts to look for (such as by group name or area of interest) and how often to run. | |
get_rfc_index.plist | Put this in your ~/Library/LaunchAgents/ folder if you want to use OS X's LaunchDaemon to automatically run get_rfc at intervals to fetch the latest RFC index file. Edit this file to select how often to run. |
Runs get_rfc . |
Edit this file to select how often to run. | |
RetroClient | Replace the file /Library/StartupItems/RetroClient/RetroClient with this file. It does the same thing (launch Retrospect daemon) but better, since it maintains a pid file, and allows the daemon to be stopped and restarted. |
Called by update_retrospect_config . |
None needed. | |
grep_id | Searches IDs that you have. You specify part of the file name and a pattern to search for; the script finds drafts with matching drafts and searches the latest matching file for the pattern. It optionally opens those where the pattern is found. | Uses list_id and optionally open_id if requested. |
You may need to edit the directory where you keep Internet Drafts. The default is IETF/Internet_Drafts in your home directory. If you need to edit this, look for the string ID_DIR .
May need to change location of dependencies if they are installed somewhere other than |
|
update_retrospect_config.plist | Place this file in the /Library/LaunchDaemons folder. When you reboot (or run launchctl manually), it instructs launchd to run this script whenever the system configuration changes. This script simply calls the update_retrospect_config script with a parameter indicating that the system configuration has changed.
|
Calls update_retrospect_config . |
None needed. | |
update_retrospect_config_reboot.plist | Place this file in the /Library/LaunchDaemons folder. When you reboot (or run launchctl manually), it instructs launchd to run this script whenever the system starts up. This script simply calls the update_retrospect_config script with a parameter indicating that the system has just booted.
|
Calls update_retrospect_config . |
None needed. | |
update_retrospect_config |
Called when system configuration changes and also at reboot.
Detects when location has changed. Selects appropriate Retrospect configuration file, then restarts Retrospect daemon. This file ( The two This script examines the current location, compares it to the location when this file was last called, and if different, figures out which Retrospect configuration file should be made active. It copies the current configuration file back where it came from, and copies the desired one as the current one, and restarts the Retrospect daemon. This script uses OS X's extended attribute functionality to save the current configuration file's source, using the handy xattr utility (see this Ars Technica article). For this to work, you need For example, if you have two saved configuration files,
Customization: Look for the line Following each network name is a line that assigns the variable
So, if you want to have two Retrospect configurations, one for work and one for home:
This script makes use of the |
|||
xattr | This command-line utility (not a script) allows access to OS X's extended attribute facility. This allows extended attributes to be set and read by scripts. Source code is available here. See this Ars Technica article for more information. | Called by update_retrospect_config . |
None needed. | |
usleep | Place this executable file in the /usr/local/bin folder. It allows the caller to pause for less than a second.
|
Called by update_retrospect_config . |
None needed. | |
usleep.c | Source code for the usleep utility.
|
None needed. | ||
format_rfc | Shell script front-end for the xml2rfc tool. | Requires that the xml2rfc file xml2rfc.tcl exist or be aliased in either the current directory, your home directory, or /usr/local/bin . |
May need to edit the directory where your xml bibliography files live. The default is individual subdirectories under IETF/bibxml in your home directory. For example, the RFC bibliography files would be in IETF/bibxml/rfc . If you need to change this, look for BIBLIO_DIR .
Uses |
|
xml2rfc.scpt | A BBEdit script (install into ~/Library/Application Support/BBEdit ) that runs format_rfc on the front-most BBEdit window. This is especially handy if you bind to a key such as ctrl-x in BBEdit. |
format_rfc |
May need to change location of dependencies if they are installed somewhere other than /usr/local/bin/ .
|
|
smugup-jb.sh |
Shell script to upload files to SmugMug site. By default, all files listed or in the specified path that do not already exist in the SmugMug album are uploaded. Can specify which album to upload to.
|
Optionally uses GraphicConverter to extract IPTC caption and keywords from image and video files. | None needed when standard utilities installed in standard locations. |