How can I take selfie by running a console command on Mac? I know I can take a selfie with the built-in camera via the Photo Booth app. However, is there a way capture an image via command line, in sort of lolcommits style?
The easiest way to do this is a program called "ImageSnap".  You can take iSight photo's by typing the command imagesnap into terminal.

All commands:

 USAGE: imagesnap [options] [filename]
Version: 0.2.5
Captures an image from a video device and saves it in a file.
If no device is specified, the system default will be used.
If no filename is specfied, snapshot.jpg will be used.
Supported image types: JPEG, TIFF, PNG, GIF, BMP
  -h          This help message
  -v          Verbose mode
  -l          List available video devices
  -t x.xx     Take a picture every x.xx seconds
  -q          Quiet mode. Do not output any text
  -w x.xx     Warmup. Delay snapshot x.xx seconds after turning on camera
  -d device   Use named video device


Just incorporate imagesnap commands into a cron job or workflow of your command.  ImageSnap is also available thru homebrew:

brew install imagesnap