From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22794 invoked by alias); 13 Jun 2018 08:11:26 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23479 Received: (qmail 28595 invoked by uid 1010); 13 Jun 2018 08:11:26 -0000 X-Qmail-Scanner-Diagnostics: from mail-vk0-f45.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.213.45):SA:0(-1.9/5.0):. Processed in 0.639348 secs); 13 Jun 2018 08:11:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: pierpaolog@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+uTiCduc03N+fn68hen8ZR6nSyNodMPgiRe6WcipFWc=; b=UZSqQcnig3qPSlpHQ1d95ajOrAMm4QwyQMbcUqf/lCk1AOeTzZrpRFodlaQQKqsluB N4uhQjqRDlXl42pxkV3YoFZxxd/i73cFSIdKl5YRM5wjvOpEcpAPavW3ZUkv6ehH9UrC wxLybfHtmRdkmDlgfA3WRzrj8g9UkNfY9K1fLyspiX0sC+o6225OgtE2Z5Jtr0jkWnNe 1M7kqGbj27yMPhD3ZzcbQK74zGObVdFt/7bDtxLARsEiMaMq/UIp/Lwh4Lh9ApzDQYi5 ddC/Czo5Ca80FPzg/scGQeOwZnFJAHCn3Y2Gjk4EzVT0hgy9/XfnjalgK4caAY2B4lrI XbKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=+uTiCduc03N+fn68hen8ZR6nSyNodMPgiRe6WcipFWc=; b=f3PUK5XtZWUWKsGk2kdq7SI1WIo33SZI2UrAQwoC4WAtuUSomzpx9nUq68kNaNGQNN 9Aeyhg4ibddGQCIPK+Cq6gmwb/ekvUiK1EZlTZ4HBt0JPw1zhtDXk11O6LAu23arixEB N5vbQk5tbpa1PBVG1DlC9vMAuLR1lewF3e2ug4FdmEbGAeu2/DY6KmAHtCwn9bg0Vmke A18TwGaEBgXad469yKm08gCvKv1EASIpQf52uT1DVKhHoG9wyp2TnVtkWVzzkUdwJvr9 rccwA9k5lraT86vq/mlznFTyDVHsxghm3DVQWQMYwfsMlkguyIjPcUB6sM1E3fWpm0op pBDA== X-Gm-Message-State: APt69E3RNxYEMurCASN+kvXr5lx+YfmAQ/2yV1GU+uPugvIAK0XtuwEH uT5qUZQOLscLsbz9Odk4PW3gm4DvOn36Gj8QojVZcNua X-Google-Smtp-Source: ADUXVKJeU+kW3+CzVqRGHQHWFdOjBWtYFSy+4i29tVEdYYe/03eLE/uqmP5tnh/UwG9wJZtQ/uvzcwmdzC1SnQ9HB74= X-Received: by 2002:a1f:ed42:: with SMTP id l63-v6mr2347327vkh.109.1528877483046; Wed, 13 Jun 2018 01:11:23 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Pier Paolo Grassi Date: Wed, 13 Jun 2018 10:10:45 +0200 Message-ID: Subject: Re: populate next comand line from precmd To: dana@dana.is Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary="000000000000483c2e056e8187f3" --000000000000483c2e056e8187f3 Content-Type: text/plain; charset="UTF-8" thank you dana, I totally overlooked print -z, that's perfect for my use case in the meantime I also rediscovered about zle-line-init, which allow the control of the next zle prompt and can get parameters from global variables. To only allow it to act when the zle prompt is a PS1 one can set a global variable in the precmd Il giorno mer 13 giu 2018 alle ore 04:55 dana ha scritto: > On 12 Jun 2018, at 20:44, Pier Paolo Grassi wrote: > >hello, I was wondering if it is somehow possibile to populate the command > >line within the precmd function. What I am trying to achieve is: from a > >normal function (not a zle widget) I would like to set some variable, to > be > >read in the precmd function where it is used to populate the next command > >line and also set the cursor position. > > Maybe print's -z option would help, at least partially? > > -z Push the arguments onto the editing buffer stack, separated by > spaces. > > Example: > > % precmd_insert_args() { > > # Check some variable, whatever > > [[ $history[$((HISTCMD - 1))] == *bar* ]] && { > > print 'Saw bar' > > print -z : inserted args '' > > } > > return 0 > > } > % precmd_functions+=( precmd_insert_args ) > % : foo # Condition not met > % : bar > Saw bar > % : inserted args > > I say 'partially' because i'm not sure if you can affect the cursor > position > (besides inserting things in front of it, obv) from outside of a widget. > > dana > > -- Pier Paolo Grassi email: pierpaolog@gmail.com linkedin: https://www.linkedin.com/in/pier-paolo-grassi-19300217 founder: https://www.meetup.com/it-IT/Machine-Learning-TO --000000000000483c2e056e8187f3--