A man charged with committing a terrorist attack in Sydney wanted to be a martyr, egging on police to shoot him after he stabbed his neighbour with a hunting knife, the Supreme Court has heard.

Ihsas Khan, 22, was charged with committing a terrorist act with the intent to influence the Australian Government. He was also charged with attempted murder.

The crown prosecutor told the court there was no disputing that Mr Khan stabbed his neighbour Wayne Greenhalgh on September 10, 2016 on Ohlsen Street in Minto, but that he was pleading not guilty, because of mental illness.

In his opening address on Monday, crown prosecutor Peter Neil SC said there was evidence to suggest Mr Khan had been planning to attack a civilian at random on September 11 to coincide with the anniversary of the Al Qaeda attacks on the United States.

But the crown said on September 10, Mr Khan picked out his neighbour, Mr Greenhalgh, because he believed he was wearing a shirt with some sort of American motif on it.

The jury heard Mr Greenhalgh was walking his dog when Mr Khan attacked him with a hunting knife, telling him he was going to kill him and saying: "You rape our women, you rape our children, you bomb our countries".

Mr Greenhalgh sustained life-threatening injuries, but managed to run into a local hairdressers.

Blood is shown at the scene of the hairdressers, where the victim hid from Mr Khan. ( ABC News: Jackson Vernon )

When Mr Khan saw the blood he was heard to say: "What a beautiful sight this is".

Locked out of the hairdressers, the court heard Mr Khan stabbed at the glass door, saying: "They killed our people, he should be killed too," "Allah Akbar" and "they tried to kill my brothers and sisters in Iraq".

The crown prosecutor said Mr Khan "wanted to be a martyr" and was heard to say "I want to die today, I'm going to die today".

He said Mr Khan wanted the police to kill him and when they arrived he confronted them with his knife and said: "What does it take to be shot by a cop?"

The crown prosecutor told the jury there was no dispute over what happened that day, but the real issue was what the accused's state of mind was when he did it.

Mr Khan had severe obsessive compulsive disorder at the time but the crown was set to argue that he would have known his conduct was wrong and he could have controlled himself.

The crown described him as a "self-radicalised extremist Muslim".

The court heard Khan was an academic high achiever who attended the selective Hurlstone Agricultural High and got high distinctions in his pharmacy degree at the University of Sydney.

However in 2013 he told his GP he thought the world was against Muslims and that he suffered anxiety attacks after watching violent videos on the internet. He subsequently spent 10 weeks in Campbelltown Hospital for psychiatric treatment.

He was born in Australia in 1993 a few months after his parents moved from Bangladesh. He had little contact, if any, with his father since he was 14. His mother died of cancer in 2015.

The trial is expected to run for four weeks.