How do I set an icon for a directory via the CLI?
You can create a shell script and name it something like mkdir_WithIconFrom

#!/bin/sh
mkdir $1
cp $2/Icon\r $1
SetFile -a C $1


This will create a directory at the first path you specify on the command line with the icon from the existing directory whose path you specify second on the command line, assuming the target directory has a custom icon.