sur un coup de tête

Etymology
From.

Adverb

 * 1)  on a whim, rashly, on the spur of the moment