How do i autorun .command files from a USB drive when I plug it in?
A launchd service supports the WatchPaths option, which launches a program when the contents of a folder are changed:


  WatchPaths &lt;array of strings&gt;
       This optional key causes the job to be started if any one of the listed paths are modified.


By watching /Volumes, a shell script can be created which would check whether your external disk is mounted or not° and run the appropriate commands°°.

° The simplest way would be checking for the presence of a /Volumes/disk-name/ folder, but it would also be the simplest to fool with by renaming the partition or having another one with the same name, causing the mount point to be modified.

°° It would be appropriate to use a temporary file storing the result of the last execution to avoid killing the Finder if another disk was to be [un]mounted.