From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 9396 invoked from network); 27 Sep 2021 08:41:30 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 27 Sep 2021 08:41:30 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1632732090; b=ryReoB8b0dqpdb4O1yV2zfI5rsaCbwRsu4Wc3UIORLESxXGSe8+TxbR3KJxnFoUg5QefI1Ma7L huYnO8e5h/Zzb/lew9F0Y6O/zE3OcB5gP46FA1ho2w5GvLAKoXK4cb0NIGgUSURChNv/oVSe37 Zp4ChDLRAk8ec0vyOAGoZEje8KW+qnq2lPrimG4pkjNjgQcl7GkQ636HUST7B5LOj8dgtNmT8P OUJAsFXgy23T1WBdmOo9HJJJiqs2K8AHqLFmi5NuTj2eJwqtaOZXHZD3SyYJq88M3D09YOtJMV w9woGnYVds1T54a/6+x316EQ60laC287DGL73JKoA0zt/w==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-qv1-f50.google.com) smtp.remote-ip=209.85.219.50; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1632732090; bh=eOTkCHuBIfA/gkfyRuIDMkDjmnOQ/05NViyHhVDjBR8=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=j6s5P86zpXyRc1IkjUMgFwYCv2LL8TyD9rE9jJBYMh/1n5QP05RD4uVcHJ+25EsK7goQ4xF7pS K+gTxkHg+VnlybfljlWVffSfkq/adicC79Q6SoezpgTqFzdaIB8LlBN1o1zMGyg6q7m1v3chL+ 2gPzjKyM4iguHPOAREAcDgN2RGm2z0ZNmgpqJ+FVQyIKSf8bIsUdWe7RCHskjnbAe5mgWs/sQb 0sMgtysNWYeSMtFBuNjnYsTAr4cgltM9GVGQT6zHqdOjhb2WRxXATn7f2S3w1Cqrj+XHoYagSO k0hcEY9/rxBw4nqAujvDRbWqJaVIC8IxraeaV9avJUQA5Q==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=cJDOgoP6Yx6GxLq2mVD58nzkkjVNrLUAcke+WYee8cI=; b=a6Xo9SPFPjHOchNTf8N9woRoit SVX4MjM5ZCUhUowtn4W6UKVY1+857PUScZHH3O7D8PmSWiVBVMAR54RuT19roKymn1Y7e1iD96XpU lR2sfU0rkioHZCtf49RY1C5UaQ7tctw/HL0VteqcH98Yc7C6RfokEkzOssgg4a38d1Xvgb0SFYnvO FF1fojBX03wSl5fCoZkZv8oIkRXhFOripQdq/NWfM+W34HTCv2x9Hsej7VxFQ9rn31ZW+DqI3/Lxv 1jMzP1liURUEnxImYhm7kMGHv2dbil0GgtHlU3jBmbEmOpg40Izh1/jFeINjWGuXjRYqOOtu0FVEb /fq3vTeQ==; Received: from authenticated user by zero.zsh.org with local id 1mUmCW-0006nS-E1; Mon, 27 Sep 2021 08:41:28 +0000 Authentication-Results: zsh.org; iprev=pass (mail-qv1-f50.google.com) smtp.remote-ip=209.85.219.50; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-qv1-f50.google.com ([209.85.219.50]:43581) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mUmBc-00066D-MF; Mon, 27 Sep 2021 08:40:34 +0000 Received: by mail-qv1-f50.google.com with SMTP id et16so1386729qvb.10 for ; Mon, 27 Sep 2021 01:40:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cJDOgoP6Yx6GxLq2mVD58nzkkjVNrLUAcke+WYee8cI=; b=Hw0avn0vXFbTbNTYDetMwImSAca+ovrTCx2vNaauTm86Y4luoNccA0Feo+sU84olJZ DIryO37anp/CgIfUko8LP4Bv+SZAC3srkr5OrgvFzV5qJPrgb8D6LHxF8wAXODR5M5eS DJb3r6yYuwePTSAg/d0I8C2qHNdqjTouKcgsNhrRmxK8RciguFHhAvUhFgK+ypfYzr8Z aorK8q/gGYUpI7R90zl5uQmov6sigG4MbnDceKs245wUENcm6nwQC6hnhzg8zc5ao8ky +X/nlalE4KzJr4Urjy3Lt+n/kpwA4DllkhONtSKYvXqLGnVk3aitbuVTzJj8XI9zNmGQ V3hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cJDOgoP6Yx6GxLq2mVD58nzkkjVNrLUAcke+WYee8cI=; b=XvC2on6KnKLgHQcmKezjXgCkbWUzsv/zyLmBP+/ihXe8qa/tKvXkSbBPBfsLr2AoTz oDd7CRj8ECjFZzzSrsn6NU5rMe+FZDengmLMz1j8conZFT/XxTR19darD4GNzTPsmfsV x4I9QNvvHQrcWBkBlJRrnZIKskbXVgk3tHnlCL7YBswxh/xL/nTgUQvT12+s0Cyiali8 IkEg1XIhJC2MIlFvfLd3zVPEYh/ZRVVczyyvfuNEXcar2oXKUun9N3ZwEtqe/M17UFH4 K9x2pN3v4Q5Jf0BhvV5lwcjcFjnknPdyWeN0hEtWK2tK4k45+hGAwhqyyH2PdrwZIpQe Qe+w== X-Gm-Message-State: AOAM533tQzArsiO00GYpeJJW4Vu/QeVrOKypMmWiEsWl1pkIG5Lxrz+h 64B3IXV/J+nA2KdRdS7uds0vZeHtlbhY4H6BUdJqhcNkNnY= X-Google-Smtp-Source: ABdhPJy66HjQmme0HowqfMeS4rIeOyKYdJQI4s/LXqVfY+MlhazRbhPtdC62P3SrzD+cujPlMhMpXfCfbwPtPVDQLs4= X-Received: by 2002:a0c:e183:: with SMTP id p3mr8796450qvl.65.1632732031322; Mon, 27 Sep 2021 01:40:31 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ahmad Ismail Date: Mon, 27 Sep 2021 08:40:20 +0000 Message-ID: Subject: Re: Select Whole, When There are Multiple Lines To: Daniel Shahaf Cc: Zsh Users Content-Type: text/plain; charset="UTF-8" X-Seq: 27140 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: List-Subscribe: List-Unsubscribe: List-Post: List-Owner: List-Archive: Here is the complete thing. Seems to be working. Please let me know if you find any issues. .... function _home-key() { REGION_ACTIVE=0 zle beginning-of-line } function _end-key() { REGION_ACTIVE=0 zle end-of-line } zle -N _home-key zle -N _end-key bindkey '^[OH' _home-key # Home key to go to the beginning of the line. bindkey '^[OF' _end-key # End key to go to the end of the line. function _ctrl-home-key() { REGION_ACTIVE=0 if [ "$BUFFERLINES" -gt 1 ]; then zle beginning-of-buffer-or-history else zle beginning-of-line fi } function _ctrl-end-key() { REGION_ACTIVE=0 if [ "$BUFFERLINES" -gt 1 ]; then zle end-of-buffer-or-history else zle end-of-line fi } zle -N _ctrl-home-key zle -N _ctrl-end-key bindkey '^[[1;5H' _ctrl-home-key # ctrl + home, go to beginning when there are multiple lines) bindkey '^[[1;5F' _ctrl-end-key # ctrl + end, go to end when there are multiple lines _select-whole() { REGION_ACTIVE=0 if [ "$BUFFERLINES" -gt 1 ]; then zle beginning-of-buffer-or-history ((REGION_ACTIVE)) || zle set-mark-command zle end-of-buffer-or-history else zle beginning-of-line ((REGION_ACTIVE)) || zle set-mark-command zle end-of-line fi } zle -N _select-whole bindkey '^A' _select-whole # Paste function _shift-home-key() { REGION_ACTIVE=0 zle set-mark-command zle beginning-of-line } function _shift-end-key() { REGION_ACTIVE=0 zle set-mark-command zle end-of-line } zle -N _shift-home-key # select till the beginning of line zle -N _shift-end-key # select till the end of line # '[[S;9H' & '[[S;9E' are defined in alacritty.yml bindkey '[[S;9H' _shift-home-key # Shift+Home to select till the beginning of the line bindkey '[[S;9E' _shift-end-key # Shift+End to select till the end of the line. function _ctrl-shift-home-key() { REGION_ACTIVE=0 zle set-mark-command if [ "$BUFFERLINES" -gt 1 ]; then zle beginning-of-buffer-or-history else zle beginning-of-line fi } function _ctrl-shift-end-key() { REGION_ACTIVE=0 zle set-mark-command if [ "$BUFFERLINES" -gt 1 ]; then zle end-of-buffer-or-history else zle end-of-line fi } zle -N _ctrl-shift-home-key zle -N _ctrl-shift-end-key bindkey '^[[1;6H' _ctrl-shift-home-key # ctrl + shift + home, select till the beginning when there are multiple lines bindkey '^[[1;6F' _ctrl-shift-end-key # ctrl + shift + end, select till the end when there are multiple lines .... Thanks and Best Regards, Ahmad Ismail On Mon, Sep 27, 2021 at 7:17 AM Ahmad Ismail wrote: > > I did not notice it earlier. The following also works. > .... > _select-whole() { > zle beginning-of-buffer-or-history > ((REGION_ACTIVE)) || zle set-mark-command > zle end-of-buffer-or-history > } > > zle -N _select-whole > bindkey '^A' _select-whole > .... > However, it works weirdly when used on single line. > > What can I do so that _select-whole works on both single and multi-lines? > > Thanks and Best Regards, > Ahmad Ismail > > On Sun, Sep 26, 2021 at 7:08 AM Daniel Shahaf wrote: > > > > Ahmad Ismail wrote on Sat, 25 Sep 2021 11:29 +00:00: > > > I mean when there are multiple lines on the prompt, the keybinding > > > only works for the line where the cursor is. How can I select all > > > lines using ctrl-A > > > > This works: > > > > f() { MARK=0; CURSOR=$#BUFFER; REGION_ACTIVE=1; } > > zle -N f > > bindkey '^T' f > > echo foo^V^Jecho bar^T # In this line, ^X means to press Ctrl+X > > > > It doesn't work in some other cases. It works when $BUFFER is > > multiline and $PREBUFFER is empty, but it doesn't work when $BUFFER is > > single-line and the previous content is in $PREBUFFER. You might be > > able to simulate that with 'P' ranges in region_highlight and > > overriding widgets that operate on the region, but it might be easier > > to just use edit-command-line.