* Re: ideas, questions, and bugs
@ 1997-10-20 20:18 Anthony Iano-Fletcher
0 siblings, 0 replies; only message in thread
From: Anthony Iano-Fletcher @ 1997-10-20 20:18 UTC (permalink / raw)
To: Zsh-workers
Hi All,
I realise that this might be an old thread by now but
I've only just got back after a fortnight's holiday.
> > > As much as I try, I can't figure out a good way to have zsh execute some
> > > command at startup and stay in interactive mode.
>
I too have wished for this and have done some strange juggling in .zshrc
files to arrange it. However I also have a patch that makes it all simple.
Basically you can have a script like:
---------------------------------------------
#! /usr/local/bin/zsh -i
# create a function which is accessible
# for use by the user.
foo () { echo bar; }
# run some start up command.
echo "Welcome!"
# modify prompt so its clear where we are.
PS1="> $PS1"
export PS1
# the user gets control here.
source /dev/tty
# clean up.
echo "Good bye"
---------------------------------------------
and this this will give the user a interactive prompt half way through the
script after defining some functions, etc.. After the user quits (via exit
or ^D) the script continues.
The actual change in behaviour only occurs when the file being sourced is a tty.
Sourcing a tty is not a common thing to do I guess so the knock on
effects are limited. In fact most of the functionality is there
anyway. This just triggers the command line editing and the prompt.
I had previously asked the list about this feature and
the reply at that time was wait a bit for the code to settle down.
This patch is simpler than my original and seems to work.
Anyway here is a patch against 3.1.2.
---------------------------------------------
*** ../zsh-3.0.1/Src/init.c Thu Oct 10 07:05:11 1996
--- ./Src/init.c Thu Dec 19 16:50:41 1996
***************
*** 799,804 ****
--- 799,810 ----
dosetopt(SHINSTDIN, 0, 1);
scriptname = s;
+ /* if its a tty we are sourcing then go interactive.....*/
+ if (isatty(SHIN))
+ {
+ dosetopt(SHINSTDIN, 1, 1); /* SHINSTDIN option */
+ }
+
sourcelevel++;
loop(0); /* loop through the file to be sourced */
sourcelevel--;
---------------------------------------------
Anthony.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1997-10-20 20:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-20 20:18 ideas, questions, and bugs Anthony Iano-Fletcher
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).