You should be automatically redirected . If not, visit
and update your bookmarks.


newLISP and the Mac Finder working together with Big Cat

It's useful to be able to run newLISP scripts when you're using the MacOS Finder. The best way I've found to do this is a free utility called Big Cat, written by Brent Simmons, ace Mac programmer and developer of NetNewsWire. Big Cat provides you with the ability to choose and run scripts from the Finder's contextual menu.

When you've installed it, put the scripts that you want to run in the ~/Library/Application Support/Big Cat Scripts/Files folder. They'll be available in the Finder when you've selected one or more files.

The basic form for a Big Cat script is something like this:

;;; change files to have a+x execution permissions
(set 'file-list (rest (rest (main-args)))) ; get selected files
(dolist (i file-list)                   ; with each file in argument
    (set 'f (format "'%s'" i))      ; quote the filename to protect it
    (exec (string "chmod a+x " f)))

This tries to change the file's execute permissions. I use this in the Finder after I've written a newLISP script (or a shell script) in a text editor. The first line skips the first two arguments, then uses the remaining arguments as file names for the dolist loop.

While you're testing your Big Cat scripts, it's useful to keep the Console application running, showing the console.log - errors and standard output are written here.

Another script I use a lot is this one:

;;; copy unix paths to clipboard
(set 'file-list (rest (rest (main-args))))
(set 'clipboard-contents nil)
(dolist (i file-list)
    (set 'f (format "'%s'" i))
    (push f clipboard-contents))
(exec (string "echo " (join clipboard-contents " " ) " | pbcopy "))

This copies the Unix paths of selected files to the system clipboard, ready for being pasted in to another application. I use this because not all applications support the Option-Drag technique for inserting the pathnames of Unix files visible in the Finder. The pbcopy command (and its pbpaste counterpart) are Unix commands for reading and writing to the pasteboard, which is the same as the clipboard. It can be a useful way of making information available to GUI applications that don't communicate with the Unix engine room.


Post a Comment

Links to this post:

Create a Link

<< Home