To customize your bash prompt to show only the relative path from your home directory (i.e., a/b instead of the full path /home/USER/a/b), you can modify your PS1 environment variable in your .bashrc or .bash_profile file.
Here’s how you can do it:
.bashrc fileOpen your .bashrc file in a text editor:
bashnano ~/.bashrc
PS1 variableAdd or modify the following line to set your prompt to show the relative path:
bashPS1='[\u@\h \W]\$ '
\W displays the basename of the current directory (i.e., the last part of the path).a/b), use \w instead of \W:bashPS1='[\u@\h \w]\$ '
.bashrcAfter saving the file, reload it to apply the changes:
bashsource ~/.bashrc
Your prompt will now show the relative path from your home directory, like this:
text[USER@HOSTNAME a/b]$
This way, you’ll always see the path relative to your home directory, making it easier to navigate and understand your current location.