bash: How to evaluate PS1, PS2, ...?
Posted
by
Harry
on Stack Overflow
See other posts from Stack Overflow
or by Harry
Published on 2012-04-08T04:57:03Z
Indexed on
2012/04/08
5:29 UTC
Read the original article
Hit count: 207
Is there any way to 'evaluate' PS1
, PS2
, etc from within a bash script?
Although, I can use alternate means to get all elements of my current PS1
, I would really like to be able to reuse its definition instead of using these alternate means.
For example,
=====================================
PS1 element --> Alternate means
=====================================
\u --> $USER
\h --> $HOSTNAME
\w --> $PWD
...
=====================================
I could very well use the 'alternate means' column in my script, but I don't want to. In my PS1
, I, for example, use bold blue color via terminal escape sequences which I'd like to be able to simply reuse by evaluating PS1
.
© Stack Overflow or respective owner