2

How to reduce the command line prefix length (i.e folder name or path in bash)?

For example:

venu@venupc:~$ cd Documents/Code/new/
venu@venupc:~/Documents/Code/new$

I want to display present folder name new instead of complete path (venu@venupc: new$).

Braiam
  • 69,112
Venu Gatla
  • 31
  • 1
  • 2
  • 5

1 Answers1

0

Read man bash, the PROMPTING section, and about the PROMPT_DIRTRIM environment variable.

  PROMPT_DIRTRIM
          If set to a number greater than zero, the value is used as the number of trail‐
          ing  directory  components to retain when expanding the \w and \W prompt string
          escapes (see PROMPTING below).  Characters removed are replaced with an  ellip‐
          sis.

Add export PROMPT_DIRTRIM=1 to ~/.bashrc, and you'll get close to what you want.

waltinator
  • 37,856