Ryan Turpin was locked up for 16-months over the incident at The Core shopping centre in Leeds city centre.
The 33-year-old was watched by security staff as he took sellotape and kitchen foil and put them down his tracksuit bottoms at the store on October 23 this year.
Louise Pryke said the defendant attracted the suspicion of staff when he appeared to pull his cap down to cover his face to avoid security cameras.
Turpin was stopped and found in possession of the large knife when he was searched.
Turpin, of no fixed address, pleaded guilty to theft and possession of a bladed article.
He has previous convictions for possessing a blade, affray, threatening behaviour, assaulting a police officer and handling stolen goods.
Martin Morrow, mitigating, said Turpin was homeless at the time of the incident.
Mr Morrow said Turpin had been carrying the knife for his own protection as "people were after him."
The lawyer said Turpin had also been struggling with mental health problems and had been abusing amphetamines.
Judge Geoffrey Marson, QC, warned Turpin that he would be facing a minimum four-year sentence if he ever received a third conviction for possessing a knife.
He told Turpin: "The combination of someone with convictions for violence, possession of knives, alcohol and drugs misuse is a recipe for a serious crime.
"The courts have to deter people from carrying knives.
"It leads to death and serious injury."