osxutils
'osxutils' is a package of MacOS X-specific command line tools. With the exception of the 'google' program, the tools are
written in C and link to the Carbon framework. They are distributed under the terms and conditions of the Free Software Foundation's
GNU General Public License. Thus, they are provided free fo charge and the source code is made available via the 'osxutils'
SourceForge project page.
osxutils contains the following tools:
Click on one of the tools listed above to get information about what they do and how to use them.
lsmac
lsmac is an ls-like utility for listing the files contained in a given
directory on HFS or HFS+ volumes. The output is akin to that of the ls long view (ls -l) but what makes lsmac unique is that
it displays the MacOS meta-data associated with the files listed, including label, file and creator types, file size in human readable
format (i.e. 12 KB, 1.2 MB), resource fork size calculated and so forth. It also lists Finder alias files like ls -l lists symlinks.
At some point I intend to patch the BSD ls program and incorporate these features for submission to Darwin but in the meanwhile I'm providing
lsmac as a standalone program.
lsmac supports a variety of options that enable you to alter and modify the output to suit your specific needs. See accompanying man
page for details.
mkalias
mkalias enables you to create MacOS Finder aliases from the command line.
The usage syntax is similar to that of ln. The alias created is identical in every way with aliases created
manually using the Finder. It gets the source file's custom icon, File and Creator type and has the kIsAlias and kHasCustomIcon
Finder flags set, making it indistinguishable from regular aliases. See image below for an example of usage.
setfctypes
setctypes is a program for the setting the heritage four-character File and Creator types of files. With the advent
of MacOS X and file suffices these identification strings no longer serve as important a purpose as before. However, MacOS X
still partly uses them to identify application ownership. The SetFile command line program that comes with
the Apple Developer tools is capable of setting File and Creator types, but it is very slow and has an awkward syntax.
See image below for an example where an MP3 file is changed from being owned by Audion to being owned by the QuickTime player.
setfcomment
setfcomment is a command line tool for setting the MacOS Finder file comment viewable in the Get Info window.
Apple introduced a new method for storing Finder comments in MacOS X. setfcomment sets both the traditional
MacOS 9> and the MacOS X comment data, so comments set with it are viewable on both operating systems.
setfflags
setfflags is a command line program for setting Finder file flags. The Finder stores all sorts of file meta-data, for example visibility,
custom icon, name locking, bundle bit, alias and stationary. Some of these flags are deprecated. setfflags allows you to change
them. In the example below, the file "song.mp3" has the invisibility flag set to true.
See the manpage for further details on syntax.
setlabel
setlabel is a command line tool that enables you to set the Finder label of files. File labels were a feature in MacOS 9> and
have been reinstated in MacOS X as of version 10.3. The two operating systems use the same method for storing and setting labels.
In the example below, the label of the file "header.psd" is changed from "None" to "Purple". Labels can be viewed with lsmac via the -L
option.
setsuffix
setsuffix provides a simple way of batch changing, setting and removing file suffices via the command line without being prompted
incessantly by the Finder. This can be very convenient when migrating suffix-free files from MacOS 9 to MacOS X, where the suffix is used to determine
application ownership. In the example below, three pictures are given the ".jpg" suffix.
See man page for further details on syntax
cpath
cpath quite simply copies the $PWD shell variable, which stores the current working shell directory, into the MacOS clipboard.
This enables you to quickly get your path for pasting into other applications. Although the same functionality could technically be replicated
with the command "echo $PWD | pbcopy", cpath does not append a newline character to the path. In the example below, the
current path is copied using cpath and then pasted using the Apple-supplied pbpaste command.
google
google allows you to easily initiate a google search in your default browser from the command line. See below for examples
of usage:
[host: /] google "The Stuff I need to find"
[host: /] google The Stuff I need to find
Both examples above are valid. The google command is implemented in Perl using Apple's open command.