Handle \~ in r_core_cmd and extend 'cd' command to handle home expansion