Posts Tagged ‘mercurial’

The little things mean so much, don’t they?  I just read a blog post about playing a “happy sound” for successful git commits. Since I use mercurial more than git, I added it to my hgrc instead.  I thought clapping was a little cheesy, so I have a Dalek saying, “Exterminate, Annihilate, Destroy!” whenever I fix a bug (based on commit message), and Vader saying, “Don’t be too proud of this technological terror you’ve created,” for new features.

The best part is that when I committed the changes to my hgrc and Vader spoke to me, I was startled—I had forgotten what I had just committed!  It made me giggle maniacally as my wife can attest.  As she noted though, I didn’t quite follow Vader’s admonition.  The next time I’m the leader of a software team, I’m going to make this mandatory.


Read Full Post »

I’ve been meaning to write a more geeky post for some time, and since I have nothing better to write at the moment, I thought I would take this opportunity to write about folder actions.

I’m going to assume that you can figure out the details of how to bend folder actions to your will. Or you at least know someone who can.  Often the hardest part of using a new technology is deciding what to do with it, so I’d like to share some ideas that I’ve found very useful.

The basic idea of folder actions is to trigger a script whenever one of the following “actions” take place:

  • adding folder items to
  • removing folder items from
  • opening folder
  • closing folder window for
  • moving folder window for

To be honest the only trigger I have used is adding folder items, which can of course be used to notify you when something is added to your Drop Box, or to perform some operations on downloaded files (e.g. move all pictures to ~/Pictures). But for me, the most useful has been taking action when a volume is mounted. This requires a little trick since the interface doesn’t allow you to attach a script to /Volumes. Firstcreate a symlink to:

ln -s /Volumes ~/vol-link

then start Folder Action Setup and add vol-link to the folders with actions list. You can then remove the symlink since Folder Action Setup follows it and will save /Volumes instead.

rm vol-link

I’m sure there’s a way to do the same thing by editing the plist files directly, but why bother?

Then you have to tell it what to do when a volume is mounted.  I use the following script (sorry there is no syntax highlighting) which simply finds the name of the volume, and runs a script (if it exists) named volumes - VOL_NAME.scpt saved in path to Folder Action scripts from local domain (you may prefer from user domain if don’t wish to share scripts with other users on the machine).

on adding folder items to this_folder after receiving these_items
	repeat with volume in these_items
		process_volume(volume as text)
	end repeat
end adding folder items to

on process_volume(vol)

	set short_name to (text 1 through -2 of vol) as text
	set script_name to "volumes - " & short_name & ".scpt"

	set FAS_folder to path to Folder Action scripts from local domain
	set full_path to (FAS_folder as text) & script_name

		run script (full_path as alias)
	end try

end process_volume

-- for testing
on run
end run

With this in place you will need something to do. I have two scripts volumes - GPOD.scpt and volumes - Kindle.scpt that I have found useful.  GPOD is the name of my iPod, and I have several mercurial repositories for configuration files, school work, etc. which are updated whenever I plug in my iPod. That way I always have the latest work with me wherever I go.

Perhaps more useful is the Kindle script. I have a folder where I drop things I want to put on my Kindle (this is especially handy since I don’t have whisper net here in Budapest with my pre-international Kindle 2). When a file is dropped in this folder, a folder action script (bet you didn’t see that one coming) looks at the extension.  If it’s directly readable on the Kindle it moves it to a holding folder, otherwise it will compose an email to Amazon to have it converted (I hardly ever use this now that the Kindle supports pdf) or throw an error if Amazon doesn’t know how to convert it. When the email comes back, another applescript should trigger off of a Mail rule to place it in the Kindle folder, but I never actually wrote that part. Then when the Kindle is attached, all files from the holding folder are copied to the Kindle and moved to a processed folder.

So, when I see something I want to read on the Kindle I simply put it in the Kindle folder knowing that the next time I plug in the Kindle it will automatically transferred.  It’s good to be lazy.  Now if only I had time to actually read everything that I have on the Kindle…

Read Full Post »