Register and run a command for a directory.