If you really want it to shift like new, just replace the housing too.
If, when you take the housing off the bike, there are kinks that you can't take out with a little hand bending, or if the plastic covering is worn off or torn, replace.
But, I can also see circumstances where I would want to re-use the housing, waste not, want not, right?
So, pull out the old cable, work the little red tube of a can of WD-40 into the housing and squirt it until it shoots out the other end. Then take an old cable, WD it and wipe it clean, cut off the old barrel so all you have is cable, run it through the housing (freshly cut end first) and pull it through, wipe it clean, rinse and repeat until it pulls through with almost no resistance. If the cable is really badly crushed or frayed where the brake bolt was, cut the worst of that off before doing this.