Fix incorrect keymap definition for OSX

Fixes #27
Only grab dirname if the path is not already a directory

Fixes #28