Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PS1 environment (in bash)

14 views
Skip to first unread message

James

unread,
Oct 31, 2017, 6:05:19 PM10/31/17
to
cat -A shows something like

^IPS1="\n$SHLVL:\h-\u-[\s-\v]-(`date +%D`-\t)-\${PWD}\n\$ "$
^Iecho "^[]0;$HOSTNAME $LOGNAME^G"$

In host-a,
ssh host-b
exit

How do I set such that when logout(exit) from host-b, it says
"Back to host-a" or even better host-a's PS1?


TIA
James


Icarus Sparry

unread,
Nov 2, 2017, 2:33:51 PM11/2/17
to
What you have should work already. You start at a prompt on host-a, sh it
will be showing you the PS1 from host-a. You run the "ssh host-b"
command, which probably will start an interactive shell on host-b, and so
show you the PS1 from that machine. You eventually type "exit" to leave
host-b. At this point the ssh should exit, and the shell on host-a should
print PS1 again as a prompt for the next command.

What are you actually seeing?

I am guessing that the echo with control characters is setting the
terminal title, which will not be updated. Normally you would have this
setting being part of your PS1 as well. Since your PS1 starts with a
newline, you could just prepend it. In general you should have it inside
a \[ \] pair (which as you are usiong double quote you should write as \
\[ and \\]) to indicate to bash that these characters do not take any
width on the screen.
0 new messages