A man caught carrying a knife had previously posted a video of himself holding a machete.
Jordan Craig, 24, is now behind bars awaiting sentence on the charges.
He admitted having an offensive weapon in Greenhills Square, East Kilbride, on September 24 then headbutting a police officer after his arrest.
Craig, of Parkfield, East Kilbride, was the subject of four bail orders at the time.
He also admitted sending threatening and offensive messages, and showing a video in which he was carrying a machete, on April 15, 2021.
Scott O'Connor, prosecuting, told Hamilton Sheriff Court that police received a call from a man at 9.15pm on September 24.
The caller said he had been threatened by a knife-wielding male in Greenhills Square and provided a description.
Officers went there and found Craig. He had a knife in his jacket pocket.
Craig was detained and taken to London Road police station in Glasgow where his behaviour became "aggressive and erratic".
The earlier incident involved a series of online messages sent by Craig to individuals between midnight and 3.30am.
He made threats, including to stab someone's dad.
One recipient came across a video in which Craig was holding a machete.
Craig has been in custody since his arrest in September.
Sheriff Liam Murphy deferred sentence until next month for background reports and warned the accused: "Given the nature of these offences and your previous convictions, custody will again be uppermost in the court's mind."
Don't miss the latest headlines from around Lanarkshire. Sign up to our newsletters here.
And did you know Lanarkshire Live is on Facebook? Head over to our page to give us a like and share.