This is a working solution for those using an external monitor on their MacBook Pro's running Yosemite. The previous terminal commands for Mavericks no longer works on Yosemite, so this how to do it.
More info on the solution can be found here: (all credit goes to rwg)
Open Terminal and enter in the following:
sudo nvram boot-args="niog=1"
sudo nvram -d boot-args
Steps after entering terminal command:
1) After putting in the terminal command, reboot and close the lid immediately
2) Keep the lid closed during boot up and once logged in, open the lid
3) Viola! The MacBook Pro's screen is turned off
*Note: If in sleep mode, just close the lid before waking the MacBook Pro and open the lid once again after logging back in.
Keep Your Connection Secure Without a Monthly Bill. Get a lifetime subscription to VPN Unlimited for all your devices with a one-time purchase from the new Gadget Hacks Shop, and watch Hulu or Netflix without regional restrictions, increase security when browsing on public networks, and more.
Other worthwhile deals to check out: