cd ~

macOS free

Recently, I picked up a new M1 macbook air. It’s taken some adjustment since I’ve been on Linux for so long but the experience so far has been great. I’ve been using NetBSD’s pkgsrc for package management of my favourite UNIX and LINUX utilities and have had very few issues building native applications on the macbook due to pkgsrc’s excellent support for ARM-based CPUs (seriously, thanks to that community for being so awesome).

One habit I couldn’t seem to break on macOS was my use of the free command. Unfortunately, free is really more of a GNU/Linux tool that isn’t typically available on non-Linux systems. Luckily, you can get your memory stats on macOS using the vm_stat command; however, the output is in pages which is really hard for my brain to process so just aliasing free to vmstat doesn’t cut it. I decided, after much searching online, to write a free command for macOS. You can grab it from the the following gitlab repo and build it if you also desire a free command on macOS: https://gitlab.com/parseltongueio/macos-free

The tool works exactly as one would expect the free command to work.

Usage:
 free [option]

Options:
 -b, --bytes	 show output in bytes
 -k, --kilo	 show output in kilobytes
 -m, --mega	 show output in megabytes
 -g, --giga	 show output in gigabytes
 -t, --tera	 show output in terabytes
 -p, --peta	 show output in petabytes
 -h, --help	 display help and exit

Eventually, I’ll get around to writing and distributing a manual and packaging it for the available macOS package managers out there. Enjoy!

Oh, and one last thing pkgsrc contributors. You’ve got a hilarious sense of humour!

pwd;perl -nE 'print if /^if/ .. /^fi/' free
/Users/parseltongue/opt/pkgsrc/sysutils/free/files
if [ ! _NetBSD = _`uname -s` ] ; then
	echo "Kid, get yerself a System: www.netbsd.org"
	exit 1
fi