The usual approach is to disconnect the lever nut, cut off the hose just below the factory barb, and then feed it through from the caliper end up to the lever. Then you turn the bars all the way and hold up the hose next to the lever and mark the spot you'll trim to for optimal length. Cut, slide on cover and nut, install new barb and olive, reconnect and bleed.
Some frames have openings big enough to get the nut, cover, and barb through, but most don't. Even if you can do this, the factory olive is smashed up most of the time anyway, potentially causing leaks if rejoined.
The fluid stays in for the most part because only one end gets opened. There are ways of doing the above that introduce little or no air and avoid the need to bleed, but people sometimes overstate how effective those tricks are as opposed to just taking advantage of Shimano brakes' ability to function with a little air in the system. It's better to just bleed it.