The built-in caffeinate
command can keep your Mac from going to sleep whilst it is running.
$ caffeinate
Use Ctrl+C to abort the command.
Use -t
to specify a timeout (in seconds)
$ caffeinate -t 3600
Would prevent your Mac from sleeping for an hour ☕