For fermenting, I just remove the gas-in keg post, fit a 1/2" hose onto the screw fitting, clamp it, and stick the other end of the hose in a glass filled with starsan. When fermentation's done, I replace the gas-in post and push to another (purged) keg. My fermentation keg's dip tube is a couple inches shorter than a regular one - that's how I avoid transferring most of the gunk.
If you want to do it all in one keg...follow the above, BUT: when primary fermentation is complete, add your priming sugar syrup, disconnect the blowoff tube, and replace your keg lid with one to which you've specially installed a spunding valve. Set your spunding valve pressure limit as desired (remember 2-2.5 volumes of CO2 at room temperature is much higher pressure than at serving temperature) and let the yeast do their thing again.
After a week or two, refrigerate the keg, attach your liquid-out post, and serve.