Starship engineer leaving bed in a mess (6)
I believe the answer is:
scotty
'starship engineer' is the definition.
(Star Trek character)
'bed in a mess' is the wordplay.
'bed' becomes 'cot' (cot is a kind of bed).
'in' indicates putting letters inside.
'a mess' becomes 'sty' (messy enclosure for pigs).
'cot' placed inside 'sty' is 'SCOTTY'.
'leaving' acts as a link.
(Other definitions for scotty that I've seen before include "Terrier" , "'Beam me up, -'" .)