If I am in a deep directory, let's say:
~/Desktop/Dropbox/School/2017/C/A3/
then when I open up terminal, it says
bob@bob-ubuntu:~/Desktop/Dropbox/School/2017/C/A3/$
and then I write my command. That is very long, and every line I write in the terminal goes to the next line. I want to know if there's a way so that it only displays my current directory. I want it to display:
bob@bob-ubuntu: A3/$
This way it's much clear, and always I can do pwd
to see my entire directory. I just don't want the entire directory visible in terminal because it takes too much space.
export PROMPT_DIRTRIM=3
in your.bashrc
is the perfect middle ground between\W
and\w
. See: https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html – spkane Nov 29 '18 at 19:45export
that to child processes. Just set it as a shell variable, as shown. – Toby Speight May 26 '21 at 12:49PROMPT_DIRTRIM=3
. But my question is Is there also the starting section settings? So the result is something like/media/user/..../endDir1/endDir2
? (specifically without editing PS1 in bashrc or at all directly...) – jave.web Sep 08 '23 at 13:26