Copy file from Terminal and paste in Mail

The following script works but it needs to open (and close) a Finder window.

Save this to maccopy:

#!/usr/bin/osascript
on run args
  set theFile to (POSIX file (first item of args)) as alias
  tell application "Finder"
      reopen
      activate
      set selection to {}
      reveal theFile
  end tell
  delay 1
  tell app "System Events"
      keystroke "c" using command down
  end tell
  tell application "Finder"
      close window 1
  end tell
  tell application "iTerm2"
      activate
  end tell
end

and chmod +x maccopy.

Use with maccopy PATH-TO-FILE.