Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to find the command that would return me evaluated value of $PS1 variable or just shell prompt with current path.



I would like to avoid using something like, since pwd will not truncate home_dir as ~.

echo "`whoami`@`hostname`:`pwd`"
share|improve this question
why is this bad question? to who ever hated. – Dolphin Oct 15 '12 at 14:45
A hack that I am too lazy to complete: run a real shell and find someway to make it believe the input is a tty. – Oct 15 '12 at 20:19
Have a look here:… – ed. Oct 15 '12 at 22:44

This is an implementation of‘s suggestion:

        $(export PS1; echo exit | sh -i 2>&1)

Of course, if you have ! in PS1, it will be evaluated as “1” — unless you have some sort of history saving going on.  User name, hostname, current directory, date & time, etc., should be OK.

share|improve this answer

You must log in to answer this question.

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