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.
Installing the Debug Flash Player on Multiple User Accounts
December 15th, 2007
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.
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
Keychain Access from a Shell.sh Script
January 17th, 2007
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. *) EOF` echo “$PASSWORD“ exit 0;
Update: As of Leopard it is now possible to do this via the command line tool security
That Dictionary File,
January 11th, 2007
the one i’m always forgetting where it hides, with the 234,936 english words in, is here
/usr/share/dict/web2
as the readme says “it makes a dandy ‘grep’ vicitim”. Want a random word?
perl -e 'rand($.) < 1 && ($line = $_) while <>; print $line’ \
/usr/share/dict/web2
Change “Welcome to Darwin!”
January 11th, 2007
Here’s how to change the “Welcome to Darwin!” message when you open a new terminal. Simply open:
/etc/motd
and change the contents to whatever you like. I favour “Welcome to Hell!”
Switching flash players on OS X
January 8th, 2006
I wrote the following shell script a while back for use with TextMate as part of my build process. TextMate’s great as it easily allows you to bind scripts to custom commands (and key combinations). However you’d easily be able to adapt it to your set up. It will allow you to cleanly change all the flash players available for OS X, as well as being able to Uninstall the player, and optionally restart open browsers (FireFox and Safari) afterwards.
You’ll need to download the players, install and move the files into archived folders the contents of which the script will copy to the default internet plug-ins folder. It shouldn’t be too difficult to work out how this happens and alter the script for your needs.
Download the script here
To install the FP 7.0.14 without restarting any open broswers:
changePlayer.sh 7.0.14 false
To uninstall the flash player:
changePlayer.sh uninstall_flash_player
To install FP 6.0.49, restarting open browsers:
changePlayer.sh 6.0.49
If there’s anyone out there using TextMate and would like a the above wrapped up in a bundle then please email me and I’ll send a copy over.
Recursively remove .svn files
December 16th, 2005
Here’s a quick shell script to recursively remove all the the .svn files starting in the current directory and working down.
find . -name '.svn -exec rm -rf '{}' \; -print
Change .svn to look for different types.
