Thanks guys, but this is not the solution I'm looking for ... Now, I ask the question in other terms: Is It possible to print of a string at the exit of a bash script? e.g.: user@mypc: # bash script has just finished! [prompt] with the prompt that remains immediately after the string printed.
Thanks, as always, for reply. > [...] > > > You have to source the script instead of running it. > > Yes, exactly. > > > I'm not entirely clear about a new shell gets it's own env that > > disappears when the shell exits thing, but try this: > > It's not only a shell thing. It's a basic Unix process thing: > child processes inherit (well, almost always) their parent's > environment -- more precisely a copy of it. They can change > their copy, but not the parent's. That's by design: lots of > loosely coupled programs calling each other (and that's what > Unix is, after all ;-) would degenerate into an unmaintainable > mess otherwise... > > > $ cat setps1 > > ##!/bin/bash > > # can i change ps1 from a script? > > echo "FOO = ${FOO}" > > export FOO=BAR > > echo "FOO now = ${FOO}" > > export PS1='\[\e]0;\u@\h: > > \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w > > #\[\033[91m\] ' > > > > $ export FOO=FOO > > $ ./setps1 > > FOO = FOO > > FOO now = BAR > > $ echo $FOO > > FOO > > > > See? FOO is back to it's pre ./setps1 value > > > > Now try > > $ source setps1 > > That's the way. There's a shorthand for "source", which is ".". So instead > of doing > > source setps1 > > you can say > > . setps1 > > Cheers > -- tomás >