Christopher Lister, who has previously been convicted of 121 offences, was less than a month into a suspended sentence order when he began carrying out a 'sneak-in burglary' at Noodle Doodle in Trippet Lane on April 4 this year.
A male member of staff at the city centre restaurant came out of the staff bathroom to find Lister, aged 33, in the process of stealing his wallet and mobile phone that he had left in an employee area, David Wain, prosecuting, told Sheffield Crown Court.
Mr Wain added: "The defendant ran on to the street. The complainant pursued the defendant, catching hold of him. The defendant was uncooperative, pulling himself out of his clothing and leaving himself topless."
The court heard how Lister then began threatening his victim while holding what the victim described as a 'black piece of plastic'.
The defendant told the man: 'If you don't let me go, I'll stab you,' before hitting the man to the head. Other staff members came to the man's aid, and managed to pull Lister off him before apprehending him and calling the police.
When arrested, Lister was found to be in possession of his victim's phone and wallet as well as another member of staff's wallet that contained Â£1,170 in cash. All of the items were recovered, the court heard.
Mr Wain said: "The defendant was interviewed and made some untrue and unpleasant allegations that I won't repeat in court. The interview came to an end when he made racist remarks."
Lister pleaded guilty to offences of burglary, assault by beating and to breaching a suspended sentence order at an earlier hearing.
Defending, David Watts, told the court that Lister, who suffers from a personality disorder, had just been released from prison and was homeless when he committed the offences.
"He was homeless, and was effectively set up to fail with that suspended sentence order, let out with nowhere to go," said Mr Watts, adding: "The defendant, through me, would like to apologise to the court and to the complainant in this matter."
Judge Peter Kelson QC jailed Christopher Lister for two years, 18 weeks during Wednesday's sentencing hearing.
He told him: "You are a habitual premises burglar, and probably a habitual sneak-in burglar. You had with you a weapon that you threatened your victim with."
South Yorkshire Police have been asked to provide a custody image of Lister.