Add history save/restore and last_cmd (.) support.