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,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 893 invoked from network); 7 Jul 2022 05:58:01 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 7 Jul 2022 05:58:01 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1657173481; b=hpdZTHS8g9vkF6xDL3+6tK8jrSKGnmkf91MlscELCA8d68pgQI1JZiSddLgJ7+iAjPy/Ry1kfG EuF1LO0Uv5sf8AFHzE3Kok2aazdQK9807fN765XbHo0aoiMbPOclyuoUHSPuBZZ+Knwq9OipoB d+9ePJLKnh1M+lRsHLyhcAd7lb02Dq0TSsf8o4nzZ6uilRafKfjlf67oJS4Ya8NJVsea0nvucB cM0GWw1ZbRARTBz9xJ/U7emdFERgGP5BwyhgPBcLtPGkJjaOqs3YKpN8vp6YUz5uF6hR2ogzBN lFlgekEZc3cuYcreZHm9HEwJMoTl4xKN+gMO+laiD33qcQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-qk1-f173.google.com) smtp.remote-ip=209.85.222.173; 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=1657173481; bh=Ou90RHfCu8R8Ft11QE0CUV2kQu8NK+TQ2J4Spyt1lVU=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:MIME-Version: DKIM-Signature:DKIM-Signature; b=XlXea6KRuyQxEVTC4Xg+nUD+TKkyMiPoL4OA0YopfWK3PZCVlkeqCzdyqIeHlGPxCLR50iFzGX 6rUJsnOBu8pVeDyhO4MaFa71arK4dncdLuInfJyX8O/jryIWWwY88/YYO5Aq/t60FlZwyeuTf/ G9mLOagpq/WB1BmouSCDHM61Vqt8p54hUwKhmeqWm2hVBHBP4tBxXTy//kZpcOr5ZNcVj0b22P X3YQlsuDtVrigpDQD4CBHJ4fY21Q/+h8J7iAQN0mngDhdPLjLM2b/bsAbeGBaR6dvkwqpfvMGQ 01HLAnTRlPITRI9Gz/z9XkklZL8Hp5vvDArO+EuCTAmB9g==; 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:To:Subject:Message-ID: Date:From:MIME-Version:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References; bh=fHmDnbUw3zuomlqREFX5JOszmwDnQIGiLw36zRItswQ=; b=gAPy4y4Y6y87BzN6lpPFNHdThG z3K1r/q7JajLymm9/ibkkxNBCyJA00DfIUUiiNPJuYipGWNoIHuzLHv/sKYPSufqui4TJPJ6aM8qd kYNj4lv36mCIo3QBdrepRgv0W6rFctpYcmS482mcfBv9yonCTYkrJf+x0YUzWoLgNFMAobvCZD64W IeMJLlC4xpaPUpX9RRQ3BrMaCmPSLwj3wzqxjqWn06kgcxiS5bYPOsolh86Nv9rwZJEMydMiep52o SMa2u5mZ88ORLxU30UWGp9yYjM3Rj9B1TAm4EMt3La0ru7vwDoq3QGGE0wdLWHcBaXYnBqRKMlwR7 BoD1k8/g==; Received: from authenticated user by zero.zsh.org with local id 1o9KWV-00062J-JM; Thu, 07 Jul 2022 05:57:59 +0000 Authentication-Results: zsh.org; iprev=pass (mail-qk1-f173.google.com) smtp.remote-ip=209.85.222.173; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-qk1-f173.google.com ([209.85.222.173]:41547) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1o9KVH-0005JH-Dk; Thu, 07 Jul 2022 05:56:44 +0000 Received: by mail-qk1-f173.google.com with SMTP id z7so12646177qko.8 for ; Wed, 06 Jul 2022 22:56:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:from:date:message-id:subject:to; bh=fHmDnbUw3zuomlqREFX5JOszmwDnQIGiLw36zRItswQ=; b=VLqfmXr7U3FUPhxDKqhC4ZTzORhjfwPspCkKwRfKPZLqZ0pO00MRUDRdDmDfNmLB+P MYCQtIMhIGxt2b3ohXOJUO5RPbUZdWL+RVvp6l2z6ceiiX1to2pIH3oo73kStJfZeUaU x++B+685+dlU7iP1fjsHN8xqRm23/6RktFufRZN2SFiJO9DkLXshQnznaqUhK0Cn0/9J BDok1z1QpCqpsbqRiGfOzGJZGBzXV6iuc7/IKhrNCRuDqUlB9yPrp8dMmy3n+flCmmai xRMbdRX2bNSveh0ELXCK//+SfH0LgWv2RzfHtnhp0EDm2TwAC7n89DPs0R+/fG08slmK rzRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=fHmDnbUw3zuomlqREFX5JOszmwDnQIGiLw36zRItswQ=; b=Rq43pLV6KubWr1Pzgeq0JUty6M50o345RePj7dgp7NSpDLFxuFarok31D3kwR2XWaN bRAgZsLpwYrVN5DIvK+ZrLOnUoExkgpO6sYh7NdM0Mq8zPoEY0GCjb8pek3+XiHX38b7 FYz/2JEowcba3DXUaaPFhydtvAe59Xq+APIeLMrHyqpQoQ2m42S28GwbpUVVb0eczqDC pcSmqXpBH7txgcTH23xtRzqu81WH+cpkoEZEJSSq5Z61eHZjztV3Y5kf7hi5C9T5gXYW 6x/rfuHw8n2ERDo5MfP1jGx8dtTdUV0ckKrnyWc+BVtlXqiEIa2xzAvkI75xy5zgrr3+ ngvA== X-Gm-Message-State: AJIora/VwaxywU2JUcD7sMaHrtliObyrpfISCFqMnsHsBXHV3gqo7dE5 TTxkFeLh6/DmVqGdr0QF8X+9SGTuR6kQv3CtoWuHxJMjhwOGlg== X-Google-Smtp-Source: AGRyM1s//skTGwwdKIBmdLhIhGZA1kk/vbxyYprtCSv7vesEVSHCtgmiXKzJ87jVKR+vvX/r5+RhxmP9vjhBSd5eNpE= X-Received: by 2002:a05:620a:4724:b0:6af:dd84:1f33 with SMTP id bs36-20020a05620a472400b006afdd841f33mr30075216qkb.464.1657173401851; Wed, 06 Jul 2022 22:56:41 -0700 (PDT) MIME-Version: 1.0 From: Ahmad Ismail Date: Thu, 7 Jul 2022 11:56:30 +0600 Message-ID: Subject: How to parse zsh history To: Zsh Users Content-Type: multipart/alternative; boundary="000000000000f2dcec05e330bfeb" X-Seq: 27869 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: --000000000000f2dcec05e330bfeb Content-Type: text/plain; charset="UTF-8" My history file looks like: .... : 1656846180:0;mint-vm : 1657092275:4;g d fpull : 1657092331:0;stow-dotfiles : 1657092447:0;fd --hidden --ignore-file .gitignore --base-directory="$HOME/.dotfiles/.common-dotfiles-buggy-nemo-bookmarks" --type l --type f | sd ^. $HOME | xargs -I{} rm {}\ : 1657092530:0;fd --hidden --base-directory="$HOME/.dotfiles/.common-dotfiles-buggy-nemo-bookmarks" --type l --type f | sd ^. $HOME | xargs -I{} rm {}\ stow --target="$HOME" --dir="$HOME/.dotfiles" --no-folding --restow .common-dotfiles-buggy-nemo-bookmarks\ : 1657092737:0;for i in "${array[@]}"\ do\ \ DOWNLOAD_URL=$(curl -Lfs ${i} | grep -m1 -Po '(?<=href=")[^"]*zip')\ FILE_NAME=$(echo $DOWNLOAD_URL | grep -Eo "([^\/]+$)")\ \ wget $DOWNLOAD_URL\ \ \ done : 1657092752:15;array=( https://cinnamon-spices.linuxmint.com/applets/view/83\ https://cinnamon-spices.linuxmint.com/applets/view/106\ https://cinnamon-spices.linuxmint.com/applets/view/222\ https://cinnamon-spices.linuxmint.com/applets/view/238\ https://cinnamon-spices.linuxmint.com/applets/view/284\ https://cinnamon-spices.linuxmint.com/applets/view/303 )\ \ for i in "${array[@]}"\ do\ \ DOWNLOAD_URL=$(curl -Lfs ${i} | grep -m1 -Po '(?<=href=")[^"]*zip')\ FILE_NAME=$(echo $DOWNLOAD_URL | grep -Eo "([^\/]+$)")\ \ wget $DOWNLOAD_URL\ \ \ done .... I am working on a widget for fuzzy search history. .... skim-history() { origquery=${BUFFER} output=$(history -1 1 | sd '^[ ]*[0-9]*[ ]*' '' | sk --tac --no-sort --exact) if [ $? -eq 0 ]; then BUFFER=$output else BUFFER=$origquery fi CURSOR=$#BUFFER } zle -N skim-history bindkey '^R' skim-history .... In `history -1 1 | sd '^[ ]*[0-9]*[ ]*' '' | sk --tac --no-sort --exact`, sd is used instead of sed, which just removes numbers from the beginning. However, it messes things up if the command is multi-line. What I found is, the only way zsh history parsing works correctly is if I use something like !NUM, to get the history. How can I edit my zle extension to do that? Another option is (if previous fails), do not save multi line commands in history. How can I do that? --000000000000f2dcec05e330bfeb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
My history file looks like:

....
<= div>: 1656846180:0;mint-vm
: 1657092275:4;g d fpull
: 1657092331:0;st= ow-dotfiles
: 1657092447:0;fd --hidden --ignore-file .gitignore --base-d= irectory=3D"$HOME/.dotfiles/.common-dotfiles-buggy-nemo-bookmarks"= ; --type l --type f | sd ^. $HOME | xargs -I{} rm {}\

: 1657092530:0= ;fd --hidden --base-directory=3D"$HOME/.dotfiles/.common-dotfiles-bugg= y-nemo-bookmarks" --type l --type f | sd ^. $HOME | xargs -I{} rm {}\<= br>stow --target=3D"$HOME" --dir=3D"$HOME/.dotfiles" --= no-folding --restow .common-dotfiles-buggy-nemo-bookmarks\

: 1657092= 737:0;for i in "${array[@]}"\
do\
=C2=A0\
=C2=A0DOWNLOAD= _URL=3D$(curl -Lfs ${i} | grep -m1 -Po '(?<=3Dhref=3D")[^"= ]*zip')\
=C2=A0FILE_NAME=3D$(echo $DOWNLOAD_URL | grep -Eo "([^= \/]+$)")\
=C2=A0\
=C2=A0wget $DOWNLOAD_URL\
=C2=A0\
\
d= one
: 1657092752:15;array=3D( https://cinnamon-spices.linuxmint.com/applets/view= /83\
=C2=A0https://cinnamon-spices.linuxmint.com/applets/view/106\
= =C2=A0h= ttps://cinnamon-spices.linuxmint.com/applets/view/222\
=C2=A0https://cinnam= on-spices.linuxmint.com/applets/view/238\
=C2=A0https://cinnamon-spices.lin= uxmint.com/applets/view/284\
https://cinnamon-spices.linuxmint.com/applets/v= iew/303 )\
\
for i in "${array[@]}"\
do\
=C2=A0\<= br>=C2=A0DOWNLOAD_URL=3D$(curl -Lfs ${i} | grep -m1 -Po '(?<=3Dhref= =3D")[^"]*zip')\
=C2=A0FILE_NAME=3D$(echo $DOWNLOAD_URL | = grep -Eo "([^\/]+$)")\
=C2=A0\
=C2=A0wget $DOWNLOAD_URL\=C2=A0\
\
done
....

I am work= ing on a widget for fuzzy search history.

....
skim-history() {
=C2=A0 origquery=3D${BUFFER}
=C2=A0 output=3D= $(history -1 1 | sd '^[ ]*[0-9]*[ ]*' '' | sk --tac --no-so= rt --exact)

=C2=A0 if [ $? -eq 0 ]; then
=C2=A0 =C2=A0 BUFFER=3D$= output
=C2=A0 else
=C2=A0 =C2=A0 BUFFER=3D$origquery
=C2=A0 fi
=
=C2=A0 CURSOR=3D$#BUFFER
}

zle =C2=A0 =C2=A0 -N =C2=A0 skim-h= istory
bindkey '^R' skim-history
....
In `history -1 1 | sd '^[ ]*[0-9]*[ ]*' '' | s= k --tac --no-sort --exact`, sd is used instead of sed, which=C2=A0just remo= ves numbers from the beginning. However, it messes things up if the command= is multi-line.

What I found is, the only way zsh = history=C2=A0parsing works correctly is if I use something like !NUM, to ge= t the history. How can I edit my zle extension to do that?

Another option is (if previous fails), do not save multi line comm= ands in history. How can I do that?





--000000000000f2dcec05e330bfeb--