Software


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

function man {
    # We can get the actual path to the man command here, so we can override
    # it with our function name.
    MAN=`which man`
    # Change these two if you are not on OS X.
    CACHE_DIR="${HOME}/Library/Caches/manpages"
    OPEN="open"

    # If we don't have any arguments, use the nice man error message
    if [ ! $1 ]; then
        $MAN
        return
    fi

    # If we have an argument that clashes with what we are wanting to be
    # able to do, pass the whole command through.
    for ARG in $*; do
        case $ARG in
            -[dfkKwtWP])
                $MAN $*
                return;;
        esac
    done

    # Make sure our cache directory exists.
    mkdir -p $CACHE_DIR
    # Get the man page(s) that match our query.
    MAN_FILES=`$MAN -w $*`
    for MAN_FILE in $MAN_FILES; do
        # Get the name of the man file, and the section.
        MAN_PAGE=`basename "$MAN_FILE" | cut -d \. -f 1-2 | sed 's/\./(/' | sed 's/$/)/'`
        # Our PDF will be in this location
        PDF_FILE="${CACHE_DIR}/${MAN_PAGE}"

        # If we actually have a man file that matches
        if [ -n "$MAN_FILE" ]; then
            # See if the man file is newer than our cached PDF, and if it is,
            # then generate a new PDF. This works even if $PDF_FILE does not
            # exist.
            if [ $MAN_FILE -nt $PDF_FILE ]; then
                $MAN -t $* | pstopdf -i -o "$PDF_FILE"
            fi
            # Then display the file.
            $OPEN "$PDF_FILE"
        fi
    done
}
View Comments (3)   RSS Feed for Comments on this Post

My sister likes to back up DVDs that her children use all of the time: they are old enough to change discs, but they tend to get scratched. So, I have been looking into backup solutions for her to use on her new MacBook.

I came across Aimersoft DVD Backup, and ran it. Not looking too bad to begin with.

The actual window, however, is appalling:

Aimersoft DVD Backup(Unregistered)

It is a little hard to see, but the window is not actually connected to the titlebar. You can actually see the objects that are in obscured windows in the gap between them!

Finally, the text from the close confirmation sheet just cracked me up:

Surely, they can tell if a copying task is in progress, and display a dialog then. If not, then just quit immediately!

View Comments (0)   RSS Feed for Comments on this Post

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]

complete -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]

Code:

complete -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.

View Comments (3)   RSS Feed for Comments on this Post

I have a couple of licenses for 1Password to give away. Leave a comment with your name and email if you are interested.

Mac only!

Update: all have been given away. Got quite a few responses in Whirlpool, before my thread was shut down.

View Comments (0)   RSS Feed for Comments on this Post

Before anyone gets excited, this isn’t about the long-awaited Finder plugin that will do for hg repositories what SCPlugin does for svn repositories: adding badges to the icons and allowing operations from within the Finder.

No, this is about using two great tools, SubEthaEdit and Changes with mercurial.

Firstly, let’s look at how we can use SubEthaEdit to be the editor for commit messages.

SubEthaEdit has a command line tool, which has some useful arguments. Use man see to see them.

The first of the ones I use is -w, which waits until the file has been closed before continuing the execution of the calling program. This is a required argument, as without it your message won’t be committed properly.

The next I use is -r, which causes the application that called see to be brought to the front after closing the file. This is not completely necessary, but saves a mouse-click.

-o new-window means open the file you are planning to edit in a new window. Again, not completely necessary, and irrelevant if you don’t use tabs at all, but I find it helps me to see which file I am editing if it appears ‘new’.

-m allows you to choose a particular mode to edit the file in. I have created a handy little hgCommit mode, so this can be used. I like this idea, as it means that lines that will not be committed are easily distinguished. And you can use a different background colour, so that it’s really clear what you are doing.

Finally, -j allows a custom title addition. Again, this is just a nicety, but I use it nonetheless.

The file ~/.hgrc allows you to have settings for an editor - I find that SubEthaEdit doesn’t quite work right with crontab, so I leave the EDITOR environment variable to nano. In the [ui] section of the .hgrc file, I have a line that looks like:

editor = see -w -r -o new-window -m hgCommit -j 'Mercurial Commit Message'

My hgCommit mode can also be downloaded, if you wish: hgCommit.mode.zip.

The next hint is using Changes. You’ll probably know this, if you have read the Changes WIki, but you can use the extdiff extension of Mercurial. The bit I missed is that you can also use Changes to merge by default. I wish you could do the same for diff.

To make Changes the default merge tool, create a script at /usr/local/bin/chmerge, or somewhere similar.

All that needs to go in this file is:

#!/bin/sh

chdiff -–wait $3 $1

And ensure it is executable. Mine is also owned by root, I think.

Then, in your .hgrc, add in the following line after your editor line:

merge = /usr/local/bin/chmerge

My final hint is how to get around errors when you have a remote filesystem mounted under sshfs, and you get an untrusted user or group error when trying to perform a mercurial operation. In my case, the files in question were owned by user 1001/group 1001. I added the following to my .hgrc:

[trusted]

users = 1001

groups = 1001

View Comments (2)   RSS Feed for Comments on this Post

Very rarely, I encounter a computer system I have to use regularly, but I don’t have superuser status on. Notably, at Uni, I have access to a SunOS system, where I actually have to use it from time to time. Most of the time this is just via ssh, but sometimes it’s a physical login to a SunRay workstation.

I much prefer bash over other shells, not because it is necessarily better, but that it is just the one I use most of the time. I’ve got some nice systems to help me out, like using a different colour for the user@host string on each machine, so I can easily see which machine the current ssh session is actually logged into.

However, at Uni there are lots of restrictions. We can run /usr/bin/bash, but we can’t change our default shell to it. In fact, we can’t change our default shell at all, which is kinda dumb. I’ve tried all sorts of tricks, but I just can’t do it.

The next step is to have your .login, or whatever, run the shell you want. For me, this is safe-ish, since tcsh (the current default shell) executes the contents of .login, but bash doesn’t. If you are using one shell that uses a particular login or profile file, and you want to change to another which uses the same file, you might struggle, or get stuck in an infinite loop. Which is probably worse.

Just having /usr/bin/bash -login in your .login file will then cause bash to run, and execute the contents of your .profile: without the -login it won’t execute the contents of said file. But what about when you exit the bash shell, using Ctrl-D, or exit, or logout, or whatever?

If you put a logout after the /usr/bin/bash -login line will cause the original shell to logout immediately after leaving the bash shell. Which is exactly what we want.

Now, all I need to do is figure out how to get rid of the line that says : tcsh: using dumb terminal settings.

That one’s too easy. Use xterm instead of xterm-color in the Settings➞Advanced area of the Terminal Preferences:

xterm-color.png
View Comments (0)   RSS Feed for Comments on this Post

Okay, this one has me stumped.

I have all of my iTunes music stored on a local server, along with the remainder of my media files (Movies, TV series, copies of Digital Photos). This has been working pretty seamlessly, until I noticed something odd.

I knew I had some files there, but they weren’t displaying. Logging into the server using ssh, or for that matter SMB showed me the files were indeed there. But whenever I logged into the server via AFP, they don’t.

Most files do, but some of them aren’t there. But if I access the share using a parent share (/home/media, instead of /home/media/music), then the files are visible again.

I am at my wits end here!

View Comments (4)   RSS Feed for Comments on this Post

With netatalk, I can serve AppleShare Filing Protocol shares from my Ubuntu box. Since this is where all of my media files are stored, this is kind of nice.

So, why use AFP over SMB (or NFS, for that matter)?

Well, I still haven’t been able to get NFS shares to work properly from my MacBook Pro. It just sits there Connecting to nfs://poul … forever. So NFS is out. (I have configured the shares under Ubuntu, or at least, I think I have. I did use the GUI tool, which as you’ll read below, didn’t fully set up the shares for SMB either…)

As I mentioned in a previous post, if you use the GUI tool to set up Samba (SMB) shares, you also need to use the smbpasswd -a [username] command.

Finder doesn’t handle Samba shares very well. It takes an age to connect to them, and if they disconnect (ie, the network disconnects, such as when you move from one location to another, and change WiFi network; or the server restarts) you get a long Finder hang while it looks for the connection.

OS X also used to disconnect Samba shares when you went to sleep, or if you slept for a long time. (This may have been the server, I don’t know) I can reconnect to an AFS share almost immediately. This means I can wake my MacBook Pro from sleep, wait a few seconds while it reconnects to the Airport network, and then press play on iTunes. All of my music lives on an AFP share, but it started playing immediately.

It is little things like this that make computing nice again.

View Comments (2)   RSS Feed for Comments on this Post

I’ve just spent about three hours troubleshooting encrypted passwords for netatalk.

Basically, the plain netatalk that comes with Ubuntu, due to licensing reasons, does not include SSL support, which means only plaintext password authentication is supported. That wouldn’t be too bad for my purposes (I’m running on a secure network), but OS X complains each time you try to connect using plaintext only passwords.

So, I followed the instructions from coderspiel: A year of plaintext AFP passwords is enough, but it wouldn’t work.

Firstly, it needs BerkelyDB 4+, but will uninstall this to install 3+, which the package manager thinks it needs. Stupid.

Secondly, some bits and pieces won’t compile. I did do some editing, but I felt this may break the whole thing, so I didn’t want to install the whole lot, just the missing uams. Basically, uams_dhx.so was missing.

So, I built this, and others, and installed them. Still no joy. I did kind of get uams_randomnum.so or something to work, but it kept saying incorrect password.

Then, I stumbled on the idea to use tail -f /var/lov/syslog. This immediately showed me I was missing the symlink from uams_dhx_passwd.so to uams_dhx.so

So that’s all there was to it. Now connections work perfectly. And AFP connections seem to be a bit more robustly handled (ie, less spinning beachballs of death), and faster for things like iTunes.

View Comments (4)   RSS Feed for Comments on this Post

Aargh! I’ve just spent ages troubleshooting SMB networking on Ubuntu, only to realise that there weren’t any SMB users - which is crazy. Why not just default to having the local users match up with the SMB users.

After finally getting that working, I did also get AFP sharing working. Which does appear to just use the users.

Still, I need to keep SMB going, for the Windows/Xbox machines that sometimes visit my network…

View Comments (0)   RSS Feed for Comments on this Post

Next Page »