Open in Textmate Service

Listening to the new podcast by the ever-present Dan Benjamin and the effervescent Merlin Mann today reminded me of the one Mac OS X service I wrote, that I use almost daily.

It allows me to right-click on the filename line in a python traceback, and have the file opened at that line in Textmate. If the file is part of an already open project, it will open in the project window (unless it is open in another window, in which case that may pop to front).

Fairly simple stuff, and should be easy to extend for other traceback/output types.

https://bitbucket.org/schinckel/open-in-textmate-service

Am I connected remotely?

I now share my dotfiles between the various OS X machines I use daily, using Dropbox and symlinks.

However, I have many aliases and functions that need to act differently if I only have a console session at the machine in question, or a full GUI session.

With bash, this is easy to test:

1export EDITOR='nano'
2if [[ -z "$SSH_CONNECTION" && $OSTYPE =~ ^darwin ]]; then
3export EDITOR='mate --wait'
4export TEXEDIT='mate -w -l %d "%s"'
5export LESSEDIT='mate -l %lm %f'
6fi

Now, if I am remotely connected to a machine, then I will get nano as my editor, but if I am sitting directly in front of it, then it will open Textmate.

Copy password button in Keychain.app

I don’t know if this is new or not, but I haven’t noticed it before. My normal workflow for Keychain.app and finding a forgotten password (ie, my Twitter one to put into a new app) is to open the password entry, and copy the value.

Today, I noticed a Copy button at the bottom of the window:

Keychain Access

This still requires you to enter your keychain password to authorise the copy, but saves a step or two.

View man pages in Preview

It’s not a new concept, but here is my take on it:

 1function man {
 2    # We can get the actual path to the man command here, so we can override
 3    # it with our function name.
 4    MAN=`which man`
 5    # Change these two if you are not on OS X.
 6    CACHE_DIR="${HOME}/Library/Caches/manpages"
 7    OPEN="open"
 8    
 9    # If we don't have any arguments, use the nice man error message
10    if [ ! $1 ]; then
11        $MAN
12        return
13    fi
14    
15    # If we have an argument that clashes with what we are wanting to be
16    # able to do, pass the whole command through.
17    for ARG in $*; do
18        case $ARG in 
19            -[dfkKwtWP])
20                $MAN $*
21                return;;
22        esac
23    done
24    
25    # Make sure our cache directory exists.
26    mkdir -p $CACHE_DIR
27    # Get the man page(s) that match our query.
28    MAN_FILES=`$MAN -w $*`
29    for MAN_FILE in $MAN_FILES; do
30        # Get the name of the man file, and the section.
31        MAN_PAGE=`basename "$MAN_FILE" | cut -d \. -f 1-2 | sed 's/\./(/' | sed 's/$/)/'`
32        # Our PDF will be in this location
33        PDF_FILE="${CACHE_DIR}/${MAN_PAGE}"
34        
35        # If we actually have a man file that matches
36        if [ -n "$MAN_FILE" ]; then
37            # See if the man file is newer than our cached PDF, and if it is,
38            # then generate a new PDF. This works even if $PDF_FILE does not
39            # exist.
40            if [ $MAN_FILE -nt $PDF_FILE ]; then
41                $MAN -t $* | pstopdf -i -o "$PDF_FILE"
42            fi
43            # Then display the file.
44            $OPEN "$PDF_FILE"
45        fi
46    done
47}

Tab completion and ssh/open -a

I use the Terminal just as much as the Finder, and have tab-completion turned on in bash. To make it better, you can set it so that it will complete differently depending upon what you have already typed in.

The first one of these tips will autocomplete from the ~/.ssh/known_hosts file, so that when you type in:

$ ssh ma[tab]

1complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh

it will autocomplete the servers you ssh to that start with “ma”.

The next one is more complicated - it allows you to complete from all available applications when typing:

$ open -a [tab]

1complete -W "$(/bin/lsregister -dump | /usr/bin/sed -E -n -e '/\/Applications/{s/^.+ ((\/Applications|\/Developer).+\.app)$/\1/p;}' | \/usr/bin/sed 's/ /\ /g' | \/usr/bin/sed -e s/\'/\\\'/g | /usr/bin/xargs /usr/bin/basename -s '.app' | /usr/bin/sed 's/ /\\\ /g')" open -a

These can be added to one of your bash startup files: mine live in ~/.bashrc.

iSync Menu

iSyncMenu.png

This stupid menu keeps appearing. I’ve turned it off several times, but it reappears.

Doesn’t seem to be every time I reboot.

rdar://6384278

iPhoto - Time to Reconsider?

Less than 12 months ago, my (effective) father-in-law bought a new Acer laptop. It came with Vista installed, and was “better than a MacBook Pro, and heaps cheaper.”

I’ve spent countless hours since then trying to get it to work smoothly. For instance, if you create a bluetooth connection to his HP printer, it prints. Once or twice. Then you need to delete the printer and re-create it for it to work. My MacBook Pro connected once, and all was good.

Another issue has been with network connectivity. He’s using a GSM USB dongle to get wireless internet, and it’s rather flaky. I plugged the same dongle into my laptop, and it worked. I can’t recall if I needed to install any software, but, and here’s the important part, if I did install a driver, it used the system’s networking stack, rather than installing another one. This is something that the PC world just doesn’t seem to get. I had to “fix” a similar problem with my sister’s machine. Using the basic Windows WiFi driver gave a much better result than the one that came with the laptop.

Finally, he decided that it was worth the effort getting an iMac. He’d then set up most of the stuff before I arrived, including the wireless internet, and all I had to do with install VMWare (and WinXP) so he can run his share-tracking program, and anything else he may have to run under Windows. Oh, and Office. I’ve got him trying out iWork, but we’ll see how that goes.

I also had to help him transfer across all of his iTunes music and photos. I’d bought my laptop with me, and had set up an ad-hoc wireless network, which I had confirmed was working. I had shared his Public directory on the iMac, and was able to connect to it from the PC, but was having trouble getting the PC share to actually appear on the Macs. Eventually I did, and copied the files across. As it turned out, I needed to change the ad-hoc network name several times as I tweaked the settings, as Windows seems brain-dead when dealing with changed network properties and the same network name. I’d hit this issue in the past when trying to connect with an old laptop (no WPA) to an ad-hoc network created by one of my machines.

I then imported all of his photos into iPhoto. Which, I discovered, is now not the clunky old program it used to be. It feels more like iTunes, but is even more snappy. It has the nice little feature of scrubbing over all of the contained images like the new iTunes view.

I think I’m going to have another try with iPhoto. I got right into Lightroom when I had a DSLR, but since I don’t take too many photos anymore, so something less high-end will do me fine.

And, I can then use the fairly cool screensaver that uses the iPhoto library to create mosaics. I’d forgotten how cool that was. I think that feature alone caused his other daughter to proclaim she too would get a Mac.

EyeTV and ScreenRecycler

Or how to make a single-display Mac Mini Media Center even better.

I have a Mac Mini that records all of my favourite programs (almost) automatically. It runs EyeTV (by default), and can play movies stored on either a local FireWire hard drive, or a LAN server (running OpenSolaris, and using ZFS, incidentally).

One annoying thing is that to set up a new smart playlist, or edit a movie, or do anything on the machine, whilst I can remote in and do stuff, this all displays on the TV.

However, using ScreenRecycler, it seems like I can trick the Mac Mini into thinking he (his name is jens!) has two monitors. Thus, with some swizzling, I can have the EyeTV full-screen display on the “real” monitor, and the desktop on the other one.

Doing this means that I can happily edit a movie (say, to remove advertisements), whilst the TV still displays the live TV (or being viewed video).

Run ScreenRecycler on the Media machine. You may need to restart if this is the first time you have run it, as it installs some driver. I’m hoping it’s pretty safe…

After running ScreenRecycler when the system has the driver installed, I needed to run JollysFastVNC to get ScreenRecycler to give me a second display. I was using ARD (and still do), which when I then reconnected showed me the whole desktop, with a menu enabling me to choose which display (or both) to view. I chose to view both displays for now.

Picture 1.png

I then loaded up the Displays preference pane, and moved the menu bar to the ScreenRecycler display.

MoveMenubar.png

I made the ScreenRecycler display run in a higher resolution (1280x960, so that it fits nicely onto my external monitor on my laptop at full-size). I then went to the EyeTV preferences, and made sure the full-screen display went onto the “real” monitor. This apparently has the side effect that quicktime movies will also play on this monitor, so that’s quite good.

EyeTVFullscreen.png

Finally, I made new Live TV and Recording open in a new window. This enables me to edit a movie while Jaq is watching another. It does, however, mean that it is a little cumbersome to switch between tuners (need to view both monitors, and do some more swizzling), but it’s workable. It was always hard to switch tuners anyway, at least with the Apple Remote.

This makes for a fairly cool setup. I’m fiddling a little more before I buy ScreenRecycler (like, does it work better upon startup?), but it looks pretty promising.

configd Kernel Panic

First KP in ages today.

Tue Jul 29 13:50:14 2008
panic(cpu 0 caller 0x00192FD4): "pmap_flush_tlbs() timeout: " "cpu 1 failing to respond to interrupts, pmap=0x6b58ae0 cpus_to_signal=2"@/SourceCache/xnu/xnu-1228.5.20/osfmk/i386/pmap.c:4570
Backtrace, Format - Frame : Return Address (4 potential args on stack) 
0x628bfa18 : 0x12b0fa (0x4592a4 0x628bfa4c 0x133243 0x0) 
0x628bfa68 : 0x192fd4 (0x45f414 0x1 0x6b58ae0 0x2) 
0x628bfad8 : 0x1932b8 (0x6b58ae0 0x200000 0x0 0x0) 
0x628bfb88 : 0x195721 (0x6b58ae0 0x215000 0x0 0x14160a8) 
0x628bfbe8 : 0x169e6f (0x6b58ae0 0x215000 0x0 0x216000) 
0x628bfd08 : 0x16a437 (0x216000 0x0 0x0 0x0) 
0x628bfd48 : 0x182517 (0x1b32618 0x215000 0x0 0x216000) 
0x628bfd78 : 0x159209 (0x1b32618 0x215000 0x45 0x11d992) 
0x628bfdb8 : 0x12d17e (0x12a66d9c 0x874e0a0 0x0 0x0) 
0x628bfdf8 : 0x126257 (0x12a66d00 0x0 0x28 0x628bfee4) 
0x628bff08 : 0x1973dd (0x628bff44 0x0 0x0 0x0) 
0x628bffc8 : 0x19f3b3 (0x6b61820 0x0 0x1a20b5 0x12b56f20) 
No mapping exists for frame pointer
Backtrace terminated-invalid frame pointer 0xbffff508

BSD process name corresponding to current thread: configd

Doesn’t really give me much info, does it.

AdiumX 1.3.1

I have, courtesy of MkConsole, the data from some of my log files displayed on my desktop. This is really useful, as I notice stuff that gets logged there.

It’s less useful when applications write more stuff to the system logs than is strictly necessary. For instance:

Picture 1.png

That’s just a small segment of the issue, but it clearly shows that the latest release of AdiumX, 1.3.1 is dumping two lines to the console or system log every minute.

For google, the logfile data that is coming out is:

> 11/09/08 6:41:18 PM [0x0-0x48048].com.adiumX.adiumX[828] INFO cmdproc.c:98:show_debug_cmd() S: 000: QNG 42  
> 11/09/08 6:41:37 PM [0x0-0x48048].com.adiumX.adiumX[828] INFO cmdproc.c:98:show_debug_cmd() C: 000: OUT  

Time to go without IM for a little while.

Might get more work done anyway. But only if I kill Twitterific too, I suspect.