A violent inmate has been sent to the State Hospital without limit of time for a catalogue of attacks in jail.
A psychiatrist said 26-year-old Ewan MacDonald posed a very high risk of danger to the public.
MacDonald left one guard - based at HMP Grampian in Peterhead, Aberdeenshire - so traumatised he quit his job after 15 years service.
Other attacks happened at Shotts, Low Moss and Perth jails between July 2017 and March 2018.
MacDonald's makeshift weapons included a sharpened toilet brush handle and a radio aerial.
He faced 13 charges, including attempted murder, but was deemed unfit to stand trial and an examination of facts hearing was held.
He was handcuffed in the dock and flanked by six security guards and a nurse from the State Hospital at Carstairs. Six police officers were also in court.
At the High Court in Glasgow, Dr Gordon Skilling, from the State Hospital, told prosecutor Lisa Gillespie that MacDonald had a dissocial personality disorder.
He said: "He has perpetrated a series of violent crimes involving carrying and using weapons, including improvised weapons, He will have little regard or remorse for his actions."
The court was told MacDonald suffered from persecutional delusions and did not accept that he had a mental illness.
Dr Skilling added: "He exhibits violent behaviour. There was a recent violent incident within the State Hospital and he would exhibit violence to the public at large."
Ms Gillespie asked Dr Skilling: "How high is that risk," and he replied: "I would say it is very high."
Robbie Christie, a guard at HMP Grampian in August 2017, said MacDonald had only been there a few days when he launched an attack on prison officers.
'Blood in my eyes'
He said MacDonald, who was armed with a broken radio aerial and a sharpened toilet brush handle, slashed and stabbed at him and two colleagues.
Mr Christie said: "Every time I was hit, it was puncturing my body. The incident was a big blur. The blood was in my eyes.
"I have never been back to the prison since. I have been diagnosed with post traumatic stress disorder. At the time, I had been an officer for 15 years."
Lady Stacey ruled that MacDonald carried out 11 of the charges.
He was acquitted of trying to kill one prison officer and seriously assaulting another at Perth jail.
Lady Stacey ordered him to be detained at the State Hospital under a compulsion and restriction order.
He will only be freed when he is no longer deemed a risk.