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

Re: append to history entry?

Ray Andrews wrote on Wed, Dec 28, 2016 at 13:24:25 -0800:
> On 28/12/16 11:20 AM, Ray Andrews wrote:
> >Ok, I'll see what I can figure out.
> Needless to say this is exploratory:
> function zshaddhistory ()
> {
> LITERAL=( "${(@s/;/)1}" )
> ... but it seems to do exactly what I want the only thing lacking is
> to associate each member of the array to the appropriate command, if
> there are several on the same line.  I can think of a few hacks that
> might do it, but is there a robust way?  Would precmd() be able to
> keep count?  Something of that nature?  This is going to come out
> right.

You can easily convert the string "$1" to a token stream, however, there
is no fully robust way to translate that token stream into a list of
commands without reimplementing the parser.

Just consider the following cases (there are more, but you should get
the gist):

    # quoted semicolon
    echo lorem\;ipsum

    # non-top-level semicolon
    (foo; bar); baz
    () { foo; bar } baz
    for 1 in foo bar; baz $1

    # non-semicolon
    foo& bar& 
    case foo in (bar) : ;; esac

    echo foo # bar ;

What are you trying to do now?  This is no longer your original
question about recording the hostname in history.

Is this about 'rap' being called in the middle of a command line…?



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