Did Rick really shoot Pete? I am not so sure.
Yes, he was in the right mind set and had plenty of reason to shoot him. Pete beats his wife, Jessie and maybe his kids. He just killed Deanna's husband, Reg with Michonne's sword. And, let's be honest, Rick is lusting after Pete's wife. Plus, he had just fought off and killed three walkers that the ever pious Father Gabriel let in the compound.
On the other hand, Rick knows that Pete is a doctor and understands his skills are very needed and also very scarce. And, quite frankly he also knows he will be able to do anything he pleases with him. After all, he did kill the leader's husband. Maybe he just wounded him.
Regardless, whether Rick killed him or not, Pete will always be the Porch Dick.