Apple - There's a "Change what happens when you close the laptop lid" setting in Windows. Is there an equivalent in OS X?

Nope, there's no such setting in OS X. This has lead to the creation of a number of sleep-prevention apps:

  • InsomniaX

    Simple app but lets you set options for each:

  • macosx-nosleep-extension

    A preference pane for enabling/disabling sleep-prevention.


You can use the command line utility pmset to change the behavior of the lid closed/open state.

To disable wake/sleep on lid state:

sudo pmset -a lidwake 0

To undo the last setting

sudo pmset -a lidwake 1

By default, closing the lid will put the Mac to sleep. Setting the lidwake 0 value will disable it meaning closing the lid will do nothing.


Steps:

  1. Connect keyboard and mouse to your macbook
  2. Connect the external display and let it be identified
  3. Connect charger
  4. Just close the lid

Works on my early 2015 macbook pro A1502 It is recommended to put your macbook to sleep before unplugging the external display.

More here > https://support.apple.com/en-in/HT201834

NOTE: I am on High Sierra, missed reading OSX while pushing the answer, but the link suggest same may work on all. Do try and leave a comment if it works!