ropen: Remote “open” command for opening remote files locally on OS X

Posted by Tom on April 4th, 2009 — in Command line, Hacks, Linux, Mac, Programming, Uncategorized

The Problem

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.

These [...]

Determining the absolute absolute path of a shell script

Posted by Tom on March 30th, 2009 — in Command line, Hacks, Linux, Mac, Programming

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.

If the script is invoked [...]

Open new Terminal tab in current directory (updated!)

Posted by Tom on October 23rd, 2008 — in Command line, Hacks, Mac

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 [...]

Command line interpreter and REPL for JSCocoa

Posted by Tom on October 10th, 2008 — in C, Command line, Hacks, JavaScript, Mac, Objective-C

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 [...]

Useful Mac OS X-specific command line utilities

Posted by Tom on July 25th, 2008 — in Command line, Mac

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 [...]

ANSI escape sequences in JavaScript (color on the command line!)

Posted by Tom on July 16th, 2008 — in Command line, JavaScript, Programming

Recently I’ve been doing a lot of work in Rhino, Mozilla’s JavaScript interpreter written in Java. While it’s a bit slower than some of the other JavaScript interpreters out there it has the advantage of being able to call Java libraries. This is immensely useful since JavaScript is pretty bare-bones in terms of built-in libraries.

Anyway, [...]

Using command line tools to detect the most frequent words in a file

Posted by Tom on March 18th, 2008 — in Command line, Linux, Programming

Antonio Cangiano wrote a post about “Using Python to detect the most frequent words in a file“. It’s a nice summary of how to do it in Python, but (nearly) the same thing can be accomplished by stringing together a few standard command line tools.

I’m no command line ninja, but I’d like to think I [...]

Presenting GCCalc: a horrible abuse of GCC

Posted by Tom on December 14th, 2007 — in C, Command line, GCC, Hacks, Linux, Mac, Programming

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 [...]

Open new Terminal window in current (or other specified) directory

Posted by Tom on September 7th, 2007 — in Command line, Mac

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

osascript -e "tell application \"Terminal\"" -e "do script \"cd $PATHDIR\"" -e "end tell"

Save this [...]

multiwhich

Posted by Tom on August 15th, 2007 — in Command line, Linux, Mac

The “which” Unix command lists the location of the first matching executable in your PATH. The GNU version of “which” has several extra features including the ability to display all matching executables in your PATH, not just the first. This is useful for finding duplicates, etc. Unfortunately, whatever version of “which” is included in Mac [...]



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/php5/lib/php:/usr/local/lib/php') in /home/tlrobinson/tlrobinson.net/blog/wp-content/themes/clean-look-150/footer.php on line 13