Kentrell Pledger, 29, is charged with attempted first-degree murder. View Full Caption DNAinfo; Chicago Police Department

COOK COUNTY CRIMINAL COURTHOUSE — A man accused of shooting at Chicago Police officers went on a tirade in court Tuesday after a Cook County judge denied him bail.

"He shot at me first," Kentrell Pledger, 29, shouted. "Get your story straight, dog."

Pledger told the courtroom he should've "smoked his [the officer's] a--" before accusing Judge Adam Bourgeois Jr., an African-American judge, of being white.

"You ain't black," Pledger said. "You're white, b----."

As deputies removed Pledger from the courtroom Tuesday, Bourgeois turned toward a court reporter to make sure she was transcribing Pledger's outburst. The judge then shook his head and said, "What they fail to understand: The law is above us all."

Earlier in the same call, a man charged with attempted rape called Bourgeois a "f---ing b---- a--" for setting bail at $5 million in his case. The judge then ordered the men held with no bail since he obviously "has no control."

The shooting incident started about 2:15 p.m. Monday in the 300 block of West 105th Place, Assistant State's Attorney Guy Lisuzzo said during Pledger's bond hearing.

Officers were on routine patrol in an unmarked car when they saw Pledger walking down the street fidgeting with his belt, prosecutors said. As police pulled over to ask Pledger a few questions, he allegedly took off running.

Police saw Pledger pull a gun from his pants as he headed into a nearby alley, Lisuzzo said. The officers gave chase, and Pledger is accused of turning and firing two shots toward police.

One of the officers pulled his service weapon and returned fire, prosecutors said, but neither police nor Pledger were injured.

Officers soon found Pledger hiding shirtless under a nearby porch, according to Lisuzzo. Pledger's red t-shirt had been wrapped around a .40 caliber handgun that was stashed under the same porch, prosecutors said.

According to an arrest report, Pledger told the officers, "Thank you for not shooting me," when they arrested him about 3 p.m. Monday.

Pledger is a Black Disciple gang member who had posted social-media images of the gun about noon Monday — roughly two hours before the alleged shooting and police chase, authorities said.

Pledger, of the 400 block of West 103rd Street, is charged with aggravated assault of a peace officer, attempted first-degree murder of a peace officer, aggravated discharge of a firearm and possession of a controlled substance.

According to his public defender, Pledger lives with his fiancee, her two children and his two children. Pledger works in a factory, the attorney said.

For more neighborhood news, listen to DNAinfo Radio here: