The woman had tried to lock herself and her young daughter in the bathroom to keep Andrew Batty out, Leeds Crown Court was told.
James Holding, prosecuting, said Batty, 28, had been handed a restraining order of indeterminate length in 2016 to stay away from his former partner.
He had been in a relationship for around three years with her and they have two children together.
Leeds thunderstorms warning as Met Office shares latest weather forecast
Bloody machete attack on busy Leeds street left man scarred for life
Paedophile arrested at Leeds Bradford Airport after travelling from Ireland to meet ‘13-year-old girl’
York Road incident: Police appeal after pedestrian killed in crash outside Leeds Dogs Trust
Leeds Bradford Airport: Full statement on August security staff strike
On June 15 this year she had been at her grandmother's address on Stansfield Road in Castleford when Batty knocked on the door and asked her if he could use her telephone.
He then barged past the grandmother and went up the stairs shouting abuse at her.
She then locked herself in the bathroom with her daughter, but Batty grabbed a fork and was able to pick the lock before lunging at her again, pressing the fork against her cheek and threatened to gouge her eye.
Batty panicked when he was told the police had been called and left.
He was arrested and initially denied the attack, but said that he and his former partner had been talking about getting back together.
Batty, of Gannet Close, Castleford, has a lengthy criminal record with more than 53 convictions, and a long history of failing to comply with court orders.
Appearing in court via video link from HMP Leeds where he was being held on remand, he admitted breaching the restraining order.
He said: "He is sorry for his actions and has not sought to dispute what he did. He is desperate to get help."
Recorder Bryan Cox QC told Batty: "This was a very serious breach, it's an important order to protect her and give her some peace of mind.
"You threatened to gouge out her eye. She must have been terrified.
"You have an exceptionally long history of breaching court orders, and you are simply not prepared to comply with them."
Batty was jailed for two years.