Suppose I do a lot of work under the directory /home/user/documents/foo, so the Bash shell prompt could appear as follows:
user@hostname: ~/documents/foo/bar/baz $ My terminal is quite narrow, and the ~/documents/foo is not a helpful use of space, since I already know I am there.
I would therefore like my shell prompt to show the working directory relative to /home/user/documents/foo:
user@hostname: bar/baz $ The prompt is defined by the PS1 environment variable, and I can find ways of editing this to include the path relative to my user's home directory, or to include only the basename, but I can't seem to get a path relative to a different directory.
$characters; I also prefer some white space separating prompts/command-output; solution: I embed a\nat the beginning ofPS1and before the$characters, eg,PS1='\n\u@\h:${PWD}\n$ '; my actualPS1is a bit more involved because I also prefer to use different colors for the\u@\hand${PWD}strings, which has the benefit of making the prompt stand out from commands and output