Use the Seldinger technique:
- Pull the shifting cable, leaving the housing in place
- Slide new wire through the shifter and then through the old housing
- Pull the old housing in the opposite direction (pull from the derailleur end), leaving the wire in place
- Slide the new housing over the new wire
- Cut wire and housing to desired length. At the derailleur end, you will want to withdraw the wire a bit (=extra wire is coming out of the shifter) so you can cut the housing without cutting the wire.
- Clamp