Case-sensitive Workspace on macos

By default, macos filesystems aren't case-sensitive. Being the default, changing this behaviour could trip up other macos apps. However, I've encountered issues where code ran locally, then failed in production: I used mismatching case when opening a file, which worked on my dev machine, but failed on the remote Linux filesystem. As a practice, I now keep a special directory for projects, and ensure it's case sensitive.

Thanks to APFS, you can keep a case-sensitive volume, and mount it wherever you wish (~/w, in my case):

$ workspace_dir="$HOME/w"
$ mkdir -p "$workspace_dir"

# Create the new volume
$ sudo diskutil apfs addVolume disk1 "Case-sensitive APFS" Workspace -mountpoint "$workspace_dir"
  Will export new APFS (Case-sensitive) Volume "Workspace" from APFS Container Reference disk1
  Started APFS operation on disk1
  Preparing to add APFS Volume to APFS Container disk1
  Creating APFS Volume
  Created new APFS Volume disk1s5
  Mounting disk
  Setting volume permissions
  Disk from APFS operation: disk1s5
  Finished APFS operation on disk1
$ sudo chown "$(id -un):$(id -gn)" "$workspace_dir"
$ sudo chmod 0700 "$workspace_dir"

# Configure the system to mount the volume on boot
$ diskutil info disk1s5 | grep -i uuid
  Volume UUID:               807005EF-C1F3-43C2-94C8-6BA6E557B3D0
  Disk / Partition UUID:     807005EF-C1F3-43C2-94C8-6BA6E557B3D0
$ echo "UUID=807005EF-C1F3-43C2-94C8-6BA6E557B3D0 $workspace_dir apfs rw" | sudo tee -a /etc/fstab
  UUID=807005EF-C1F3-43C2-94C8-6BA6E557B3D0 /Users/username/w apfs rw
$ sudo automount -vc
  automount: /System/Volumes/Data/home updated (/home -> /System/Volumes/Data/home)
  automount: no unmounts

Now, case sensitivity works, but only under that folder:

$ touch ~/w/{t,T}est
$ ls ~/w/
test    Test
$ touch ~/{t,T}est
$ ls ~
test    w