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?
Asked
Active
Viewed 8,988 times
5
dessert
- 40,956
asdfkjasdfjk
- 391
1 Answers
7
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
Use \w instead of \W for the full cwd path.
Related questions
dessert
- 40,956
