Terminal command that gives the type of computer you're on
This command should work for you:

sysctl hw.model


This will return the Model Identifier for your machine. The below is an example for a mid-2012 Retina MacBook Pro:

Machine123:~ username$ sysctl hw.model
hw.model: MacBookPro10,1


Below are some references on Apple's site that describe Model Identifiers - there doesn't seem to be a single reference:

MacBook Pro Model Identifiers

MacBook Model Identifiers

MacBook Air Model Identifiers

iMac Model Identifers

Mac Pro Model Identifiers

Mac Mini Model Identifiers