C17: from French, from Italian capriccio a shiver, caprice, from capo head + riccio hedgehog, suggesting a convulsive shudder in which the hair stood on end like a hedgehog's spines; meaning also influenced by Italian capra goat, by folk etymology
1667, from Fr. caprice "whim," from It. capriccio "whim," orig. "a shivering," probably from capro "goat," with reference to frisking; but another theory connects the It. word with capo "head" + riccio "curl, frizzled," lit. "hedgehog," from L. ericius. The notion is of the hair standing on end in horror.