From: Anthony Iano-Fletcher <Anthony.Iano-Fletcher@cbel.dcrt.nih.gov>
To: Zsh-workers@math.gatech.edu
Subject: Re: ideas, questions, and bugs
Date: Mon, 20 Oct 1997 16:18:59 -0400 (EDT) [thread overview]
Message-ID: <199710202018.QAA10896@argo.dcrt.nih.gov> (raw)
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.
reply other threads:[~1997-10-20 20:25 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199710202018.QAA10896@argo.dcrt.nih.gov \
--to=anthony.iano-fletcher@cbel.dcrt.nih.gov \
--cc=Zsh-workers@math.gatech.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).