E. Cobham Brewer 18101897. Dictionary of Phrase and Fable. 1898.
is cocky surepertly confident. We call a self-confident, overbearing prig a cocky fellow, from the barnyard despot; but Shakespeare employs the phrase in the sense of sure as the cock of a firelock.
We steal as in a castle, cock-sure.Shakespeare: 1 Henry IV., ii. 1.
The French phrase is à coup sûr, as Nous réussirons à coup sûr, we are certain of success, Cela est ainsi à coup sûr, etc., and the phrase Sure as a gun, seem to favour the latter derivation.