Most Mac OS X power users know about the “open” command line tool which opens the files specified as arguments in their default (or a specified) OS X application. Additionally, many OS X text editors, such as TextMate (”mate”) and SubEthaEdit (”see”), come with command line tools which can be used to open files.
In the course of working on projects like server-side Objective-J, jack, and now narwhal, I’ve often had to write shell scripts that needed to know their location in the filesystem. Rather than hardcoding it, I prefer to infer it automatically at runtime. Unfortunately this isn’t as easy as you would expect.
I recently heard about an RSS reader (can’t remember which) that had a feature to mark all messages older than a certain threshold as “read”. I thought this was an incredibly useful feature, since I often forget to check my feeds for days at a time, and end up with hundreds of unread items that [...]
This is an updated shell script / AppleScript for opening a new tab in your current directory (or the specified directory). The last version was for the pre-tabbed version of Terminal.
#!/bin/sh -
if [ $# -ne 1 ]; then
PATHDIR=`pwd`
else
PATHDIR=$1
fi
/usr/bin/osascript <<-EOF
activate application "Terminal"
tell application "System Events"
keystroke "t" using {command down}
end tell
tell application "Terminal"
repeat with win in windows
try
if [...]
A few months ago I started working on a JavaScript to Objective-C bridge. We had already implemented Objective-C in JavaScript, so I figured “why not?”
Well, I never got very far, but thankfully Patrick Geiller apparently had the same idea and actually executed it: He announced JSCocoa today. It looks like it’s a solid bridge, about [...]
One of the greatest strengths of Mac OS X, for developers in particular, is that it has a very elegant and consistent graphical user interface as well as an excellent command line interface. I’m not going to cover the basics like “ls” and “cd”, but rather point out some Mac OS X specific tools that [...]
Mac OS X comes with an Apache installation which is very handy, but by default it’s configured not to follow symlinks. A lot of times I have projects in other directories which I want to share via the web server, but end up getting errors such as the following:
Forbidden
You don’t have permission to access /~tlrobinson/Editor/ [...]
Back at MacHack 2003 Jonathan Rentzsch talked about how to override functions and inject code in Mac OS X using several neat tricks. He also released a framework called mach_star which has two components: mach_override and mach_inject. These are great, but overkill for some simple cases.
A much easier way of doing library function overrides is [...]
Following an interesting discussion on Reddit about first class functions in C, I was inspired to see what I could do with this new-found knowledge. The result is what I affectionately call “GCCalc”, for reasons that will become clear below.
GCCalc is a simple command line calculator, much like the common bc calculator on many Unix [...]
A lot of times I find myself wanting to open another (Mac OS X) Terminal window in the same directory as my current one. This little shell script, which executes a little AppleScript, makes that trivial:
#!/bin/sh
if [ $# -ne 1 ]; then
PATHDIR=`pwd`
else
PATHDIR=$1
fi
Warning: include(/home/tlrobinson/tlrobinson.net/_footer-analytics.php) [function.include]: failed to open stream: No such file or directory in /home/tlrobinson/tlrobinson.net/blog/wp-content/themes/clean-look-150/footer.php on line 13
Warning: include() [function.include]: Failed opening '/home/tlrobinson/tlrobinson.net/_footer-analytics.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/tlrobinson/tlrobinson.net/blog/wp-content/themes/clean-look-150/footer.php on line 13