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

Re: History in Non-Interactive Shells



I'm not sure if it's exists but you could try this hack

preexec() { LASTCMD=$THISCMD; THISCMD=$1 }

Then make use of the $LASTCMD env variable from within vi.


On 11/28/06, Chris Johnson <cjohnson@xxxxxxxxxx> wrote:
Is there any mechanism in zsh for accessing history in non-interactive
shells?  An application I see for such a mechanism is in invoking the
shell from within an application when I only know a bit of the command.

For instance, when editing in vim a source file myapp.c that creates an
application myapp, it'd be great to be able to call the executable
without closing vim and instead calling ":!myapp" to find the last call
to myapp with the appropriate arguments.  (I already make the executable
without closing vim.)

I could probably conjure up something by reversing the history file in
sed and grep'ing the result for the root name of the source file.
Either operation is probably a little expensive, but I thought I'd
check.

--
Chris Johnson
cjohnson@xxxxxxxxxx
http://www.cs.utk.edu/~cjohnson



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