Menubar app Caffeine can keep your Mac from falling asleep for a set amount of time, but if you want to control sleep yourself, through the OS X Terminal, you can do so very easily with a simple command.
User Ricket on StackExchange shares this neat little command line tip. To keep your Mac awake, all you have to do is open Terminal on your Mac (Macintosh HD -> Applications -> Utilities -> Terminal) and enter the following command:
When you're ready to allow your machine to sleep again, you just need to press Control + C.
pmset noidle [Stack Exchange]
Republished from Lifehacker