2

I use Terminator terminal. As you can see from the screenshot below, everywhere it shows the directory names. Instead of showing whole directory names, I want it to show only the last directory name i.e ecommerce in this case. Is there a way to do this?

enter image description here

  • Thanks for the solution. However your solution works for title and tab title but in the terminal the it still shows whole directory name. Here I would also like to have only the last name. Is it possible by any chance? – asdfkjasdfjk Aug 10 '19 at 14:35
  • This last solutions did not change anything. I have updated the photo in the question. I would like to change the blue marked directory names to show only last directory name. Your above solutions successfully change the title but it would be nice if I can change the blue marked name as well. – asdfkjasdfjk Aug 10 '19 at 16:22
  • 1
    Excellent. That worked like a charm. Thanks a lot. If you put this as answer, I can accept it. – asdfkjasdfjk Aug 10 '19 at 17:15
1

Open your ~/.bashrc in your preferred text editor and search the PS1 line, by default it says

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

To change your prompt, i.e. the coloured part in front of every command line, to show only the current working directory’s name instead of its path, change \w to \W:

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ '

To set the terminal’s (or terminal tab’s) title to the cwd you need to append \[\e]2;\W\a\] to this line, this can be done e.g. at the end directly before the closing ' or – because the line is long enough – on a separate line directly afterwards:

PS1=$PS1'\[\e]2;\W\a\]' # set terminal title to cwd

Related questions

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.