How to tell if I'm using HFS+ or APFS?

Using diskutil, or other command line tools, how can I determine which filesystem I'm using?

# sw_vers
ProductName:    Mac OS X
ProductVersion:    10.8.5
BuildVersion:    12F45

The easiest way is using the diskutil command line as follows:

diskutil info /

You will see a report which will include something like this for an APFS formatted storage:

Volume Name:              Macintosh HD
Mounted:                  Yes
Mount Point:              /
Partition Type:           41504752-0000-11AA-AA23-01306543EFEA
File System Personality:  APFS
Type (Bundle):            apfs
Name (User Visible):      APFS
Owners:                   Enabled

See under Type to determine what kind of file system is on your root volume.

This will be displayed on an HFS formatted storage:

Volume Name:              Macintosh HD
Mounted:                  Yes
Mount Point:              /
Partition Type:           Apple_HFS
File System Personality:  Journaled HFS+
Type (Bundle):            hfs
Name (User Visible):      Mac OS Extended (Journaled)
Journal:                  Journal size 155648 KB at offset 0x3a38000
Owners:                   Enabled

If you want to automate this or use the results in a script, you can use following one-liner:

/usr/libexec/PlistBuddy -c "Print :FilesystemType" /dev/stdin <<< $(diskutil info -plist /)

Which will produce output:

apfs

or

hfs