Apple


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:

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

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.

View Comment (1)   RSS Feed for Comments on this Post

I was having some issues connecting to (although not pinging) python.org and some of the python-subdomains: notably the CheeseShop (http://pypi.python.org).

I disabled IPv6, and they all cleared up.

I don’t know if this was an issue with Internode’s IPv6 stuff, but it was being handled by my Airport Extreme. My iPhone was working fine, because it doesn’t use IPv6.

What a relief.

I had tried everything I could think of: from changing my DNS server, DHCP server, I even tried a reinstall of my OS (although this wasn’t why I did that - I wanted a cleanup of my dev machine).

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

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 Comments (0)   RSS Feed for Comments on this Post

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 Comment (1)   RSS Feed for Comments on this Post

The active tab looks wrong.

Inactive tabs not so much.

Safari_Loading_icon.png

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

Dear Apple,

Please send me the battery that you said you would. I’m not really liking when I see this:

battery.png

That’s not much fun at all.

Regards,

Matt.

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

A Note on Automounting MacFUSE File Systems

Mac OS X, like many other Unix-like operating systems, includes the “autofs” file system layer that make automatic on-demand mounting of remote resources possible. See the man page for automount(8) for more details.

[From Mac OS X Internals: The Blog » Blog Archive » A Note on Automounting MacFUSE File Systems]

Awesome. This might replace the need for ExpanDrive. And be even more automatic.

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

I discovered, quite by accident the other day, that it is possible to use an NSSegmentedControl to control which Tab of an NSTabView is displayed. Here is how to do it.

First of all, it is much easier to change the selected tab if you leave the tabs on to begin with. So, I would suggest building all of the NSTabView’s tabs first. I’ve done five, each with a different control.

View1.png View2.png

Now, you can alter the NSTabView so it doesn’t show the Tabs:

View1Tabless.png TabViewInspector.png

You can now add the NSSegmentedControl, and style it as you wish. I really like the Small Square styling.

SmallSquareNSTabView.png

Now to hook up the connection. There is an outlet on NSTabView called takeSelectedTabViewFromSender:, which can be hooked up to an NSSegmentedControl.

Connection.png

You will need to ensure that your initially selected cell and view are the same index, which prohibits having it save the value between runs (or you might be able to, if you know more than me).

View Comment (1)   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

Next Page »