Gavin Inkster, 31, told shocked staff at the Sainsbury Local that he was armed with the four inch kitchen blade before fleeing the store in October last year.
Inkster - a convicted sex offender - was caught by police nearby and claimed he had downed alcohol and 40 Valium tablets before confronting the shop staff.
The yob became notorious when he was labelled ‘Scotland’s Worst Teenager’ following a string of offences which resulted in the first ever county-wide ASBO banning him from the whole of Midlothian.
Inkster was also convicted of sexually assaulting a girl under the age of 13 in an alleyway in Musselburgh, East Lothian, in 2013.
He was placed on the Sex Offenders’ Register for two years and sentenced to 240 hours of unpaid work in the community.
Inkster pleaded guilty to knife possession and behaving in a threatening or abusive manner when he appeared via a video link at Edinburgh Sheriff Court last month.
He was in the dock in person today where Sheriff Alistair Noble was told Inkster also had two previous convictions for possessing an offensive weapon.
Lawyer Christopher McFarlane, defending, said his client had suffered “a downturn in his mental health” which had led to his latest offending.
He added that Inkster “accepted responsibility” for the knife offence and the labourer had employment open to him if he was to escape custody and serve a community sentence.
But after hearing the solicitor’s representation the sheriff sentenced Inkster to a 12 month jail term backdated to October.
Previously the court was told Inkster told the Sainsbury’s worker he was carrying a knife while reaching into his jacket pocket.
The worker didn’t see the knife but the court was told a colleague did.
Police were called and Inkster was traced carrying the kitchen knife near to the store at the city’s Causwayside on October 11.
The court heard Inkster was subsequently taken to hospital for treatment to self-inflicted knife injuries to his left arm.