Apache Bundle Upgrade

February 11th, 2008

The Apache bundle, which I originally contributed in the early days of TextMate, was due an upgrade. So I’ve made a few improvements…

Start, Stop, Restart and Graceful commands (⌘R)

These commands, which all target apachectl, are now bound to ⌘R under the source.apache-config scope which makes it more convenient to directly control httpd from TextMate.

As apachectl requires sudo privileges I used applescript for authentication. For reasons only known to Apple the password request dialog would launch but not get focus - leaving you to reach for the mouse to target the input field. Moving away from the keyboard is slow so this was something that really annoyed me. I’ve now switched to using the excellent tm_dialog system which makes things much smoother.

It is also possible to store your admin password in your Keychain, this is done by selecting the “Add to Keychain” toggle in the password request dialog box. I’m more than happy with the security implications of this as I’m fairly good at keeping my machines locked. If you do choose to do this then the command line security app will have access to the keychain item and is the only way someone could gain access.

Documentation (⌃H)

This now searches a documentation index file for the current word/selection then redirects or presents a list of matches as appropriate. If you appear to have the documentation installed locally then the script favours it over the apache website.

Open Include (⇧⌘D)

The language definition has been improved to add a scope for Includes. Using the key combination apple-shift-D on this scope opens the file referenced by the inlcude, or directory if it is wild carded.

Open Config… (⇧⌘C)

Previously there were various commands to open the apache.conf files these have now been consolidated into one command which searches the apache install directory, either /etc/apache2 or /private/etc/httpd depending on your version of OS X and the /users, /extra and /other subdirectories. All the conf files found are presented in pop-up from which one can be choosen to open.

Bundle Configuration

It is now possible to override the default bundle behaviour by setting the following environmental variables. TM_APACHE_DIRECTORY, TM_APACHE_ACCESS_LOG, TM_APACHE_ERROR_LOG and
TM_APACHE_MANUAL_URI all allow the custom targeting of files and directories. See the bundle help for a detailed explanation.

Open Bundle as Project…

January 2nd, 2008

I’m often opening the bundles I develop - and nosing through the others - as projects, and doing so via the Finder or the File > Open menu is long winded. To speed up the process here’s a small command which searches the default bundle locations and presents all the bundles in a dialog. Pick the one you’re interested in and TextMate opens it as a project. That’s if it’s enabled, when it’s not the default behavior is to enable it, second time round it will open as a project.

Download

HelvectorLight Theme

December 23rd, 2007

I’ve just updated the ActionScript 3 Bundle to include an ASDoc language definition. This is essentially a scope change of Luke Daley’s JavaDoc language definition. The result is that the following scopes within the documentation blocks are brought under new colour jurisdictions.

keyword.other
entity.name.tag
punctuation.definition.tag

For me, using my favourite theme - Twilight - the extra colour where I was so used to seeing grey wasn’t working. To combat it, and get things greyscale again, I added 3 new theme elements and applied them to the following scopes:

comment.block.documentation keyword.other
comment.block.documentation entity.name.tag
comment.block.documentation punctuation.definition.tag

The results are the HelvectorLight.tmTheme which calms things down again.

Download

I share one of my development machines with another flash developer and have run into a problem whereby the debug flash player was only available to the user who installed it. Trying to set more generous permissions on the plug-in didn’t work. So I simply changed the name of the plug-in by prefixing it with the installing users name then reinstalled it as second user. This leaves you with multiple instances of the flash player in Library/Internet Plug-Ins but as each user only has permission to use the player they installed no confusion arises.

The most recent debug player can be found here. An archive of debug players can be found here.

TextMate Ant Bundle

October 30th, 2007

Following on from my work with the Apache, ActionScript, ActionScript 3 and Flex TextMate Bundles, comes a bundle for the Ant build system. It is available for checkout here which I’d recommend for the most up to date version, or download as a zip here.

Ant Bundle

As a Flash developer who’s been working with Flex and ActionScript 3 since late last year I really couldn’t bring myself to use the Flex Builder Eclipse plug-in. This down to my addiction to TextMate, in my opionion it simply out classes the competion. As a result I’m responsible for TextMate’s ActionScript 3 and Flex bundles.

At the moment the bundles are in the review section of the TextMate Repository. Once installed the bundle help covers how to set up (primarily to download the flex sdk) and outlines the non-obvious commands.

The main highlights of the bundles are:

  • MXMLC and FCSH Build Commands.
  • Function, Tag, Import Auto Completion.
  • ActionScript 3 and Flex documentation search.
  • Drag and Drop of imports, includes, embed assets, css, xml.
  • ASDoc Support.
  • MXML Validation.
  • Manifest Generation.
  • Class and Component Templates.
  • Flex Builder compatible project creation.
  • Unused Import statement removal.
  • Shortcut Key Super Class, Code Behind and Import file opening.
  • Thanks to the following people who have all had a hand, although they may not know it, in the creation of the bundles:

  • Daniel Parnell
  • Theo Hultberg
  • Mark Llobrera
  • Joachim
  • ChromaticRain
  • Thomas Aylott
  • For those of you who don’t use subversion the following zip’s can be downloaded, but they won’t necessarily be the latest version :

    ActionScript 3 Bundle
    Flex Bundle

    Using svnX via svn-ssh

    February 5th, 2007

    This is a relatively simple thing to do, and it’s really all about setting up shh rather than svn, but when you don’t quite understand what is happening it’s a little creepy having the authentication handled automatically. The shh authentication process uses a public / private key system which is explained nicely here.

    To start you need ssh to use keys rather than passwords. This is because subversion needs to “transparently” authenticate each time you make a request. I hope I’m right in thinking that it opens a tunnel to the remote machine and invokes the service as a svnserve process there.

    So, open a terminal window and type ssh-keygen -d to generate your public and private ssh keys. Hit return at each prompt to stick with the default options. You’ll end up with two files called id_dsa.pub and id_dsa in your pwd move the files to ~/.ssh/. Then you need to copy the contents of id_dsa.pub to this file ~/.ssh/authorized_keys on your remote machine ( the one hosting the subversion repository) - creating it if it doesn’t exist. You can append more than one public key to the authorized_keys file if you’re connecting from more than one machine. If you have access to more than one user account on the the remote machine then you need to copy the key into each users authorized_keys file. I used CyberDuck along with a sftp connection to get the onto the remote machine. You should then be able to login to the remote machine using username@server.org.

    Once you’ve got the ssh connection verified it should be plain sailing with svnx. You’ll be able ot use your repository with the following

    svn+ssh://username@domain.com/path/to/repository

    I’ve just found this on the TextMate blog. It’s covering the same ssh key generation process, but using the command line completely, and describing how to set up ssh aliases to save a little bit of typing.

    Terminal to Finder

    January 22nd, 2007

    I’ve been using the terminal more and more and began to find the process of nipping back and forth between it (at the pwd) and the Finder a little tedious, typing:

    open -a "Finder.app" .

    was hardly difficult but I figured that it would be handy to shorten it down to simply typing finder. To do this I’d imagined that I’d have to create a binary executable for one of the bin folders. Thankfully it was simpler than that, it’s possible to put plain old shell scripts in the bin folders and have them execute. So in /usr/local/bin I created a file called finder, inside which I put the following:

    #!/bin/bash

    open -a "Finder.app" .
    exit 0;

    chmod 755 the file and it worked. The only other thing you may need to do is make sure that you have the following line :

    export PATH="$PATH:/usr/local/bin"

    in your shell profile ~/.profile

    svn ignore

    January 20th, 2007

    How do you get subversion to ingnore certain files? It can be done globally or on a per directory basis.

    For global ignores find your subversion config file. For me this was here ~/.subversion/config then edit the following line, here I’ve added *.tmproj to ignore any file which ends with .tmproj (the * being a reg exp for any prefix).

    global-ignores = *.o *.lo *.la #*# .*.rej *.tmproj

    To ingnore files on a per directory basis cd to the directory in question and use the following.

    svn propset svn:ignore "*.cache" .

    This will apply the ignore to the file or files specifed by the pattern. In this case all files ending with .cache. The trialing . applies the ignore to the current directory, but can be the path to any subversion directory. The command above creates a .svn/dir-props file with the following contents in the specified directory.

    K 10
    svn:ignore
    V 8
    *.cache

    END

    Here’s a useful snippet to enable you to securely store passwords in OS X’s keychain and use them in a shell scripts.

    #!/bin/bash
    
    PASSWORD=`exec osascript <<EOF | tr “\r” “\n”
    
        (*
         To use the Keychain to store the admin password then 
    
         Open /Applications/Utilities/Keychain Access.app
         Add a new keychain called “TM”
         Add a Key with the name “test” and store your password in it.
    
         I’d recommend learning how keychains work then tailoring
         the process to your security needs.
        *)
    
        tell application Keychain Scripting
            set myKeyChain to keychain TM.keychain
            set theKeyList to every key of myKeyChain
            set thePassword to “”
            repeat with x from 1 to (length of theKeyList)
                set theKey to item x of theKeyList
                if the name of theKey is test then
                    set thePassword to password of theKey
                    exit repeat leaves us without
                    a value returned to the shell script…
                end if
            end repeat
        end tell
    
    EOF`
    
    echo $PASSWORD
    
    exit 0;

    Download:

    Update: As of Leopard it is now possible to do this via the command line tool security