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

Re: zle separability



On Apr 25, 12:51am, Frederik Eaton wrote:
}
} Thanks. I guess there's always writing a zsh script to do the
} interfacing, but that wouldn't be ideal.

The Functions/Misc/nslookup script in the zsh distribution is the
classic example of doing this.  If your underlying command doesn't
expect to print its own prompts on a terminal, you can even leave
out the zpty stuff and just do a "while vared" loop.
 
} (... but, by the way, it would still be nice if such uses for zsh were
} better supported, with for instance support for reading an arbitrary
} config file or executing an arbitrary fragment before opening an
} interactive shell, or for a function which can be defined to handle
} all interactive commands)

Interactive shells are for interacting with the shell.  You don't need
an interactive shell to interact with some other command.  E.g. to
repeatedly read command-line arguments of "dig" and then call dig with
those arguments:

zsh -c 'while line=""; vared -e -p "$0: " line; do $0 $=line; done' dig

The use of $0 means you can replace "dig" above with any other command
name and it'll work the same way.  It's a little trickier if you want
to add history support, but not too bad.



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