POSIX path or POSIX file

POSIX path or POSIX file

set f to choose file — f is a file object

set p to POSIX path of f — p is Unicode text of the path

set f1 to POSIX file p — f1 is a file object again

set qp to quoted form of p — qp is a path string you can send to Terminal even if it contains spaces or special characters

Changing keyboard equivalents

Changing keyboard equivalents

The following example would set the Activity Viewer menu item of mail.app to be command+shift+A:

defaults write com.apple.Mail NSUserKeyEquivalents ‘{“Activity Viewer”=”@$A”;}’

The odd characters before the ‘A’ in the previous command, specify the modifiers:

* @ = Command * $ = Shift * ~ = Option * ^ = Control

To use other keys, such as Delete, you will have to use their Unicode codes like this:

@U0008 which would mean command+Delete.

This is really good, since it does not involve modifying the original application, and only applies to your environment, leaving that of others unchanged. I will try to make an app to handle this proceedure some time in the future.

Logging out via AppleScript

From Chris Nebel of Apple’s AppleScript Engineering group

ignoring application responses
¬†¬†tell application “loginwindow” to <>
end ignoring

The double pointy brackets around the raw event call should be replaced by option-backslash and shift-option-backslash.The “rlgo” is short for “really log out”; if you want the “are you sure you want to log out” dialog, use aevtlogo instead. A future version of AppleScript will have a real command similar to “shut down”.

PHP – FTP timeouts

Warning: ftp_site(): Transfer completed. 23188 (8) bytes transferred. in /Library/WebServer/Include/IIWheader.inc on line 102 Error: Site command failed.

I think I’m experiencing a timeout on a long running query. I found a couple of references to commands to address this issue and tried them to no avail.

set_time_limit(6000);
$old_max_execution_time = ini_set(“max_execution_time”, 6000);
$fn = rdb_query($conn_block, $host, $db, $query);
ini_set(“max_execution_time”, $old_max_execution_time);

the fix

ftp_set_option($conn_id, FTP_TIMEOUT_SEC, $runtime);

arrow keys in Terminal.app

export TERM=dtterm

this seems to make my arrows work when and where I want them to.

cool. and I can edit in Radio still

There are problems (sometimes) with emacs and other tools.

If you do this you probably don’t want “lynx” to be in color, so make lynx work like this

TERM=vt100; lynx

as a single command.

immutable flag on files

locked files got you down? might be immutable. see “chflags”

uchg set the user immutable flag (owner or super-user only)

The chflags command is your friend.

Fonts in GLterm

GLTerm is a very nice Terminal replacement, the only one which runs mc flawlessly. Unfortunately, the choice of fonts is quite limited. To use custom fonts in GLTerm you need:

1. Installed X11 from Apple or through fink 2. The getbdf utility (click here to download)

Choose a font visible to X11 (the fontname should look like ‘-adobe-utopia-bold-i-normal-‘. These names may be found in the fonts.dir and fonts.alias files under /usr -> X11R6 -> lib -> X11 -> fonts). You may try ‘fixed’ or ‘lucidasanstypewriter-12’ aliases to get the default X console font or Lucida, as well.

Start X11, go to the xterm window. You can see if your font name is correct by executing /usr/xterm -fn [fontname]. If you see no error message and you like the font in the new xterm window, you may proceed. Execute getbdf -font [fontname] > [newfontname].bdf in xterm.

Note the redirection (>), getbdf outputs to stdout by default. Copy the resulting .bdf file to /Applications -> GLterm.app -> Contents -> fonts (if your GLterm is in /Applications), either in the console or through Control-Click and Show Package Contents in the Finder. Restart GLterm, go to Preferences -> Appearance, and your custom font should be available in the list.

[Editor’s note: I tested this hint, and it works as expected, although it’s a bit more complex than expected. The one thing that threw me at first is that there are subdirectories in the “fonts” folder, and it’s those subdirectories that hold the fonts.dir and fonts.alias files. To find all the files easily, just type:

% cd /usr/X11R6/lib/X11/fonts % find . -name “fonts.*”

This will list all the fonts.dir and fonts.alias files in the various subdirectories. When you’re looking in those files, the names of the font is quite long. For example, in the fonts.dir file in the “misc” subdirectory, a random font name is:

-misc-fixed-medium-r-normal–14-130-75-75-c-70-iso10646-1

You need to use that entire string as the name of your font in order for this to work. When you use the redirect, give it a nice short name!]

Screen Shot Format

Apple’s Cocoa Development mailing list archives contain an interesting snippet that explains how to change the default screenshot (command-shift-3 and -4) format from TIFF to JPEG, PICT or PNG. The original article can be seen here (read the dialog box for the username and password), but it’s basically a one-line terminal command:
defaults write NSGlobalDomain AppleScreenShotFormat imageFormat

Replace imageFormat with one of JPEG, TIFF, PNG, or PICT to change the format of the screenshot