``` [USER@HOSTNAME ~]$ mkdir a [USER@HOSTNAME ~]$ cd a/ [USER@HOSTNAME a]$ mkdir b [USER@HOSTNAME a]$ cd b/ [USER@HOSTNAME b]$ ```
How to make the whole home folder relative path shown in the last line, that is `a/b`?
Mar 26, 1:34pm
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:
Step 1: Edit your .bashrc file
Open your .bashrc file in a text editor:
bash
nano ~/.bashrc
Step 2: Add or modify the PS1 variable
Add or modify the following line to set your prompt to show the relative path:
bash
PS1='[\u@\h \W]\$ '
\W displays the basename of the current directory (i.e., the last part of the path).
If you want to show the full relative path (e.g., a/b), use \w instead of \W:
bash
PS1='[\u@\h \w]\$ '
Step 3: Reload your .bashrc
After saving the file, reload it to apply the changes:
bash
source ~/.bashrc
Result
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.
Mar 26, 1:34pm
This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.