How to replace the home directory with a tilde? Linux
问题 I'm currently making a shell in C++ and I've been able to output the absolute directory as the prompt with getcwd(), however when the user reaches the home directory I would like to output a tilde instead of the home directory. So for example instead of [bb@bbmachine bb] I would like to output [bb@bbmachine ~] How would I do something like that? 回答1: Read first about globbing, notably glob(7). For the expansion of path starting with tilde ~ consider wordexp(3) and glob(3). For showing a path