Article 5PR01 [SOLVED] Change PS1 just locally, for the current shell session -> not possible?

[SOLVED] Change PS1 just locally, for the current shell session -> not possible?

by
dedec0
from LinuxQuestions.org on (#5PR01)
Sometimes, i want to change PS1 to something more simple, something really minimal, just to copy more easily the output of a session, or a set of commands. But i am unable to do this, and i do not understand why. Can you help me? PS1, as i understand, is a shell variable, to start. And its value is specially treated by the shell at the end of every command we execute. We can customize it in our settings. But my value for it seems kind of frozen. Why? I do not want to change its value in bashrc. I just want a temporary arbitrary value for it. After my need ends, i can just close this temporary session, or 'source' the bashrc file.

A session with comments:

Code:
021.09.19 18:48:20 [ 0] me@compo: ~
$ # first, let's see what is the current prompt magic:

021.09.19 18:48:21 [ 0] me@compo: ~
$ echo $PS1
${debian_chroot:+($debian_chroot)}\[\033[0;36m\]\D{%Y.%m.%d}
\t\[\033[00m\] \[\033[0;35m\][`printf "% 3d" \$?`]\[\033[00m\]
\[\033[00;34m\]\u@\h\[\033[00m\]:
\[\033[01;32m\]\w\[\033[00m\]\n\$

021.09.19 22:38:20 [ 0] me@compo: ~
$ # Now, let's "destroy" it to a minimal sign

021.09.19 22:38:21 [ 0] me@compo: ~
$ set $PS1="a"

021.09.19 22:42:55 [ 0] me@compo: ~
$ # It did not work?! The value of PS1 variable is stil the
same??

021.09.19 22:42:55 [ 0] me@compo: ~
$ echo $PS1
${debian_chroot:+($debian_chroot)}\[\033[0;36m\]\D{%Y.%m.%d}
\t\[\033[00m\] \[\033[0;35m\][`printf "% 3d" \$?`]\[\033[00m\]
\[\033[00;34m\]\u@\h\[\033[00m\]:
\[\033[01;32m\]\w\[\033[00m\]\n\$

021.09.19 22:43:02 [ 0] me@compo: ~
$ # Fine. Sometimes, we must export the var, or it is just
local to something

021.09.19 22:43:03 [ 0] me@compo: ~
$ set $PS1="a"; export PS1

021.09.19 22:43:20 [ 0] me@compo: ~
$ # So, it did not work... maybe, we do not write the "$" for
the set command?

021.09.19 22:43:21 [ 0] me@compo: ~
$ set PS1="a"

021.09.19 22:43:33 [ 0] me@compo: ~
$ # Still nothing... let's try wihtout "$" and with export,
then:

021.09.19 22:43:34 [ 0] me@compo: ~
$ set PS1="a"; export PS1

021.09.19 22:43:48 [ 0] me@compo: ~
$ # Still frozen. What is wrong with me??latest?d=yIl2AUoC8zA latest?i=IfOAknhaPkE:NXSv5P7yaVQ:F7zBnMy latest?i=IfOAknhaPkE:NXSv5P7yaVQ:V_sGLiP latest?d=qj6IDK7rITs latest?i=IfOAknhaPkE:NXSv5P7yaVQ:gIN9vFwIfOAknhaPkE
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments