Exporting $PS1.

Ag. Hatzimanikas a.hatzim at gmail.com
Sun Mar 11 12:50:24 PDT 2007


I came across from a post by Bart Schaefer, one of the lead zsh developers.
He clearly mentions that exporting the PS1 variable it doesn't make
sense in modern shells.

Bart Schaefer wrote:

> The use of "export PS1" is sensible in the old Bourne shell and in a
> strictly POSIX shell, because there is no file that is read by every
> interactive shell (only ~/.profile read by login shells).  It doesn't
> make sense in bash or zsh, because ~/.*shrc can set it and the various
> replacements (like zsh's %m and bash's \h for the machine name) are not
> compatible anyway, if you happen to start up some other shell.

I am using zsh as my login shell and I made a small experiment.

Steps:
1.
a) Removed ~/.bashrc
b) Export the PS1 in ~/.zshrc.

Result:
[ag][401](~)bash
[%{%}%n%{%}][%{%}%h%{%}](%{%}%~%{%})


2.
a) Removed ~/.bashrc
b) Assigned the PS1 in ~/.zshrc without exporting the variable.

Result:
[ag][401](~)bash
bash-3.1$ echo $PS1
\s-\v\$

Conclusion.
Exporting the PS1 variable is a bad idea.



More information about the blfs-dev mailing list