1

I'm able to change the terminal prefix with PS1="[\\W]$".

However, whenever I restart the terminal or open a new instance, it reverts to the default.

How can I make this change permanent?

Thanks!


Here's the content of ~/.profile file:

PS1="[\\W]\\$"
  • try echo 'PS1="[\\W]$"' >> $HOME/.profile – jm666 Jun 18 '13 at 19:41
  • Nope, that doesn't work. – Aram Boyajyan Jun 18 '13 at 19:43
  • 1
    @downvotes - what's wrong with the question? – Aram Boyajyan Jun 18 '13 at 19:43
  • thats works. Simply you need add it into the .profile file. – jm666 Jun 18 '13 at 19:43
  • Thanks for messages jm666 but it seems to be there already. I just updated the question with contents of my .profile file. – Aram Boyajyan Jun 18 '13 at 19:46
4

If both .bash_profile and .profile exist, bash reads only .bash_profile when opening a login shell. So try adding the line to .bash_profile instead.

  • 1
    Don't just jam things in .bash_profile. Things you want to apply to all interactive shells should go in ~/.bashrc. Only things you want in login shells should go in ~/.bash_profile. ~/.bash_profile should source ~/.bashrc to pick up the stuff you want in all interactive shells. – Chris Page Jan 11 '16 at 23:20
  • In particular, login shells can be non-interactive, so avoid doing interactive-shell setup in ~/.bash_profile or the other profile/login scripts. – Chris Page Jan 11 '16 at 23:48
1

Most Bash shell customizations, including the PS1 shell prompt, should be set in ~/.bashrc, which applies to all interactive shells.

You'll also need a ~/.bash_profile—which should only contain items for login shells—and it should source ~/.bashrc, e.g.,

[ -r ~/.bashrc] && . ~/.bashrc

If you have a ~/.profile it should only contain POSIX-compatible commands and nothing Bash-specific, which means you should prefer to use ~/.bash_profile for login commands when you have a ~/.bashrc for it to source.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .