How to prevent applications on an external hard drive from showing up in the "Open With" contextual menu?

Try this procedure:

  1. Exclude your second drive from Spotlight indexing (or, if you want to keep access to it via Spotlight, just exclude its /Applications folder) by dragging its icon into the Privacy pane of the Spotlight System Settings. This will preclude Launch Services from seeing the apps on the drive and re-registering them in the next step.
  2. Make Launch Services reload the list of available apps with the command /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -all local,system,user. As apps on the second drive are not available via Spotlight anymore, the new database will only contain those on your main drive.
  3. Restart Finder to rebuild its Open With context menu (Option-right click on its Dock icon to get the restart option, or do killall Finder in Terminal).