Shame the court didn't also order the deportation of the violent Somali criminal.
Derby Crown Court heard yesterday that the attack by Fosi Farah left Ian Wright, 53, with a 3cm gash in his skull and terrifying flashbacks.
Gillian Foxcroft, prosecuting, said Mr Wright had been walking along Green Lane, towards a bank when the attack happened.
She said: "He had walked past a man holding a bottle of alcohol.
"Soon after, he realised he was being followed and suddenly he felt a thud on the top of his head."She said Mr Wright turned and saw the man he had passed earlier coming towards him armed with a hammer.
In interviews, Mr Wright said 43-year-old Farah seemed to be trying to attack him again. He kicked out at his attacker, who then dropped the hammer and ran off.
Ms Foxcroft said that Farah, of Wilson Street, Derby, told a nearby policeman what he had done.
She said: "He could not give a reason why he had done it, other than the voices in his head told him to."
Farah pleaded guilty to possessing an offensive weapon and wounding with intent to commit grievous bodily harm.
Judge Andrew Hamilton ordered that Farah should be detained in a mental health hospital and undertake medical treatment.
It will be for an unspecified length of time, until doctors feel it is safe to release him.
He said: "It is clear from the evidence that you are suffering from a mental illness.
"If there was not a medical disposal I would take the view that this man was extremely dangerous and would lock him up for life."
Ms Foxcroft said witnesses had seen Farah swing the hammer up high and bring it down on the victim's skull.
Other witnesses said the attack and the victim's screaming and shouting afterwards was "a terrible thing both to see and hear".
Somalian-born Farah had been living in the UK for a number of years. He was unemployed at the time of the attack.
Peter Pimm, in mitigation, said Farah had been suffering from schizophrenia for more than 15 years and had experienced suicidal tendencies.
The court ordered the destruction of the hammer.
Instead he will be detained and treated at our expense until a doctor deigns him fit to be released on an unsuspecting public once more.