Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: allow zsh to source a script and then become interactive



Thanks Bart. 

That's cool. However this gives one PS1 prompt as extra output. So I
have to set PS1='' before I call zsh and then set PS1 inside the
payload script.

Demo: Create the setup file

% cat >/tmp/setup <<END
PS1='>>> '
date
date
xxxx () { echo "hello"; }
END

Run zsh - added -f to ignore my start up files

% zsh -fis <<<"source /tmp/setup </dev/tty && exec </dev/tty"
teapot% Fri Apr 14 17:53:13 EDT 2017                                            
Fri Apr 14 17:53:13 EDT 2017
>>> xxxx                                                                        
hello
>>>                                                                             

See the extra "teapot% " prompt that sneaks in. Instead run

PS1='' zsh -fis <<<"source /tmp/setup </dev/tty && exec </dev/tty"

and it does the desired thing. Brilliant.

		Anthony. :-)


On 14 Apr 2017 at 13:28:58, Bart Schaefer wrote:
> On Apr 14, 12:55pm, Anthony Fletcher wrote:
> }
> } This is an oldie but goodie that I don't have a solution to. How can I
> } invoke a zsh that sources a particular file (not the standard start up
> } files) and then become interactive, preserving functions, etc?
> 
> This should do it:
> 
>     zsh -is <<<"source $aparticularfile </dev/tty && exec </dev/tty"
> 



Messages sorted by: Reverse Date, Date, Thread, Author