To set an icon on a file or directory is straight forward using the "Get Info" dialog in Finder.
- copy image from e.g. Preview
- open "Get Info" on file or directory
- press TAB to select the icon
- paste Cmd-V
But how do you do this using the command line?