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_KAM_HTML_FONT_INVALID,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 8921 invoked from network); 29 Oct 2020 23:54:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 29 Oct 2020 23:54:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1604015696; b=j8hYs7ApOKUHX83ElHQwN/Zv/M3Yv5NSj9MKgIay25+emupmglD1eGQ5GQh6CsIPH/g50CABZC Q2AjZZyCTYWKGNsb3odU5Y3uA0dKx8lN77bIWZESpFbcPnTAk+5vR9REDfGsMx9Lba4UKMYbZX +NmegnXuN2tLx3wCfvXMr+Bljs9u4lpJhMvTh8LlkHh68Gsbfa7kztBMALDbR+fQzbElxPRIXs TJs77AczuhJCFOZZyEf+jKe//Z/j0CCjLitnbxa86JY6chA4Zr3SDffyL/wfvb1wJeLgOpyK7G 9rmVsYflMnKUXn1u1Pxy/YnfWWcWmces9R5/xWqFn5A2IQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-oo1-f42.google.com) smtp.remote-ip=209.85.161.42; dkim=pass header.d=gmail.com header.s=20161025 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-20200801; t=1604015696; bh=SjXdlMBqPF+TLkZ9cYplzFoiMfwezk0IFCy+NtN/+/k=; 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=qrMGpVumcl5jKXgUpM9UztJl2uBkycD16tOGWM/hJ1sbCmX2sHClWjiCroQdPkSOtBA+bSkqSl 2D3F4XllktpZMNyzC9Nz6XdObw+/sbZTF/jlED9s3cvI12yvhZcZSJmWJkGHNfzgibdFbows3I TkXF3Hi4O5NrSrd1xQxLpdx9n6O1RpFlQV52dRa3SadgIMrxEACDEz8GQisUOVaCcOmMHJGltO kO/i6Ou1kLD8uCj8rwVOWUB83BkMcc4GkvO2lpXJTLsriFAodaVmewD5+EYaxM+W9oVT0FSm1y x8+GpCiRS2nuBZ2q8RGy3Tf/3pqOGyB2kWG18lMKrH8Xig==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20200801; 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=SpN6KK8/A0SXVVuhck5pfYUGxHJBz7OCo/SBB487U4Y=; b=MePA3h7DEVHVt2uU2uq9rFH0im BCvpQKspiML9vlDviQoK2puvgJsQXGT0L3oeG7eEcPD3BIyKMzY38mErBA0p68fRa18zQR4nLzl03 10ck74hPuG1Jjs5mxqrVwd2qlgNYSTPiofC5my/Q4Lqk9p0kBNFkNZiWy2uwtwgxFjmBAuIJKE8D2 eYdoiqMgT54sxIYhoHIG1hO91EChZATUHOtp45Hwp37r15dF3W2y0jkf3hdaKv3vyQLZCl/wU1zyj jjHDbBOrzS4OOnDaHQqwX5aBE/d+ugj4rk6qAwWIFwxopphVW/MRg3MnZu8tFOumupehQcjjrlIzv ZQQyOCMw==; Received: from authenticated user by zero.zsh.org with local id 1kYHku-0005G3-9q; Thu, 29 Oct 2020 23:54:56 +0000 Authentication-Results: zsh.org; iprev=pass (mail-oo1-f42.google.com) smtp.remote-ip=209.85.161.42; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-oo1-f42.google.com ([209.85.161.42]:35493) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1kYHkQ-0004tE-4u; Thu, 29 Oct 2020 23:54:27 +0000 Received: by mail-oo1-f42.google.com with SMTP id n16so1179814ooj.2 for ; Thu, 29 Oct 2020 16:54:26 -0700 (PDT) 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=SpN6KK8/A0SXVVuhck5pfYUGxHJBz7OCo/SBB487U4Y=; b=upNRevCkajPW6o+8ji5NcfZWVOLAEBw6LVFMKjmhHxhWS+QrGzTsl12e50NdzKtZdP 6tN2eUo/AU2YFn9prkalr22ZuP//1N0T6BOG5nitKhXSdAHmPjSWHWWR2Du0WjEDcBWz 1GrH/Ol3qIHVadm0mw1vMdGi2ul969hCVFlru17bRyN2dlqVPpprvX7aJIQR8eRaZ/7z OW9joOP9eAnrdVDYgmss+cFKiTNjojP6Rz2Ojn/6641F06kRlBtj7u1y9cqLobPzCeDL YFxSAOfovUDkgAnlj3Yqg4KV4PIPIuwKyS4nfNVhJqEqhzi1xZjqUWwl5L5PSqOGvQrb RKNg== 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=SpN6KK8/A0SXVVuhck5pfYUGxHJBz7OCo/SBB487U4Y=; b=IwqlmAldI9+IoVKD51HG5rMrzc5rv3OJd0OowldocG6WfS267m6apmcYC2RQSCdqUW vL3/CBgXHLdunzWUGXjL5Lqw++3XnD3WrSrbfi14lHjnP4E4VNlLSVDfGrFZBPySVilx EiG0TjEMFAsRMrVVtBAt/pHty51+GQ2rdaTYtNBTOKfhx1VrDbD6osFeB7Gfsx5VXN/P NOkO48/Y2z2ijYEIGYvPGCuVX+LnE74Jxel11k11EInzrfci6B3Br0cL6Wyab0Xvkbos imk0FO7ob2S4rZs2iVBowSUeCUyIUptwSfl/oAW1a2TultAbp2h/YcYQH7sTqwWgQtRl k0kA== X-Gm-Message-State: AOAM5338nEW/l/rkvqAMCuuar66i8CKQwYTOElCRwv9kWU29PoxKJA0+ VqSxFXQ5ABE3QQj7CAWZdBigGD5JNjvOsZ7o3cg= X-Google-Smtp-Source: ABdhPJz0XS/wHNPG/FfrgCzATLB+PaeAY3fcmtFnYvCu8XNOHZ/+7qyJVz2Nfs7k+jO+Meq7bVlYnKjsy/HJVQqBW/A= X-Received: by 2002:a05:6820:345:: with SMTP id m5mr5224045ooe.59.1604015664863; Thu, 29 Oct 2020 16:54:24 -0700 (PDT) MIME-Version: 1.0 References: <0E85AE23-69A6-41EB-AC00-8EEF5587DF03@covisp.net> In-Reply-To: <0E85AE23-69A6-41EB-AC00-8EEF5587DF03@covisp.net> From: Ahmad Ismail Date: Fri, 30 Oct 2020 05:54:13 +0600 Message-ID: Subject: Re: save a command in history from within the widget To: Lewis Butler Cc: Zsh Users Content-Type: multipart/alternative; boundary="000000000000eb1be105b2d7ffcb" X-Seq: 26140 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: Archived-At: --000000000000eb1be105b2d7ffcb Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Lewis Butler, The problem I was trying to solve is given in https://www.reddit.com/r/git/comments/jdl11c/can_not_use_some_of_my_aliases= _with_bare_repo/ https://stackoverflow.com/questions/64416625/can-not-use-some-of-my-aliases= -with-bare-repo let me explain the code you referred to. accept-line widget is invoked after we press enter in the command line. I replace that with _check-if-dotfile-command using the following line zle -N accept-line _check-if-dotfile-command The code took the command (which is in the $BUFFER) and replaced it with another string and then ran accept-line widget. For example any line starting with `g d stash-and-reset` was replaced with `git d stash && git d reset --hard HEAD`. *Thanks and Best Regards,Ahmad Ismail* On Thu, Oct 29, 2020 at 5:07 PM Lewis Butler wrote: > On 24 Oct 2020, at 13:00, Ahmad Ismail wrote: > > I am currently working on a widget. It is used so that I can use my git > alias also for my dotfiles. > > This is, to me, very advanced zsh and while reading through it I am still > not exactly sure what it does or what the purpose is. > > > The widget is given bellow: > > > > function _check-if-dotfile-command { > > > > if [[ $BUFFER =3D~ ^"g d untrack-all" ]] > > then > > zle .kill-whole-line > > BUFFER=3D"g d rm --cached -r ~" > > zle .accept-line > > elif [[ $BUFFER =3D~ ^"g d add-and-commit" ]] > > then > > BUFFERz=3D$(echo $BUFFER | cut -d '"' -f2) > > zle .kill-whole-line > > BUFFER=3D"git d add ~ && g d commit -am \"${BUFFERz}\"" > > zle .accept-line > > elif [[ $BUFFER =3D~ ^"g d sb" ]] > > then > > zle .kill-whole-line > > BUFFER=3D"git d branch | rofi -dmenu | xargs git checkout" > > zle .accept-line > > elif [[ $BUFFER =3D~ ^"g d stash-and-reset" ]] > > then > > zle .kill-whole-line > > BUFFER=3D"git d stash && git d reset --hard HEAD" > > zle .accept-line > > elif [[ $BUFFER =3D~ ^"g d last" ]] > > then > > zle .kill-whole-line > > BUFFER=3D"git d --no-pager log -1 --oneline" > > zle .accept-line > > else > > zle .accept-line > > fi > > } > > > > zle -N accept-line _check-if-dotfile-command > > I currently have a directory named ~/.shell which is a git repo for all > the various . Files in my home folder (via hard links). What is the widge= t > intended to do and how is it triggered? > > (I realize you've moved away from this widget, but what were you trying > for). > > -- > =C9=B9=D7=9F=CA=87nq=D7=9F > > tel:+1.303.219.0564 > > > > > --000000000000eb1be105b2d7ffcb Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Lewis Butler,

The problem= I was trying to solve is given in


let me explain the code you referred to. accept-line widget is inv= oked after we press enter in the command line. I replace that with _check-i= f-dotfile-command using the following line

zle -N accept-line _check-if-dotfile-command

Th= e code took the command (which is in the=C2=A0 $BUFFER) and replaced it wit= h another string and then ran accept-line widget. For example any line star= ting with `g d stash-and-reset` was replaced with `git d stash && g= it d reset --hard HEAD`.


Thanks and Best Regards,

Ahmad= Ismail



On Thu, Oct 29, 2020 at 5= :07 PM Lewis Butler <lbutler@covis= p.net> wrote:
On 24 Oct 2020, at 13:00, Ahmad Ismail <ismail783@gmail.com> wrote:
> I am currently working on a widget. It is used so that I can use my gi= t alias also for my dotfiles.

This is, to me, very advanced zsh and while reading through it I am still n= ot exactly sure what it does or what the purpose is.

> The widget is given bellow:
>
> function _check-if-dotfile-command {
>
>=C2=A0 =C2=A0 =C2=A0if=C2=A0 [[ $BUFFER =3D~ ^"g d untrack-all&quo= t; ]]
>=C2=A0 =C2=A0 =C2=A0then
>=C2=A0 =C2=A0 =C2=A0 =C2=A0zle .kill-whole-line
>=C2=A0 =C2=A0 =C2=A0 =C2=A0BUFFER=3D"g d rm --cached -r ~" >=C2=A0 =C2=A0 =C2=A0 =C2=A0zle .accept-line
>=C2=A0 =C2=A0 =C2=A0elif [[ $BUFFER =3D~ ^"g d add-and-commit"= ; ]]
>=C2=A0 =C2=A0 =C2=A0then
>=C2=A0 =C2=A0 =C2=A0 =C2=A0BUFFERz=3D$(echo $BUFFER | cut -d '"= ;' -f2)
>=C2=A0 =C2=A0 =C2=A0 =C2=A0zle .kill-whole-line
>=C2=A0 =C2=A0 =C2=A0 =C2=A0BUFFER=3D"git d add ~ && g d co= mmit -am \"${BUFFERz}\""
>=C2=A0 =C2=A0 =C2=A0 =C2=A0zle .accept-line
>=C2=A0 =C2=A0 =C2=A0elif [[ $BUFFER =3D~ ^"g d sb" ]]
>=C2=A0 =C2=A0 =C2=A0then
>=C2=A0 =C2=A0 =C2=A0 =C2=A0zle .kill-whole-line
>=C2=A0 =C2=A0 =C2=A0 =C2=A0BUFFER=3D"git d branch | rofi -dmenu | = xargs git checkout"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0zle .accept-line
>=C2=A0 =C2=A0 =C2=A0elif [[ $BUFFER =3D~ ^"g d stash-and-reset&quo= t; ]]
>=C2=A0 =C2=A0 =C2=A0then
>=C2=A0 =C2=A0 =C2=A0 =C2=A0zle .kill-whole-line
>=C2=A0 =C2=A0 =C2=A0 =C2=A0BUFFER=3D"git d stash && git d = reset --hard HEAD"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0zle .accept-line
>=C2=A0 =C2=A0 =C2=A0elif [[ $BUFFER =3D~ ^"g d last" ]]
>=C2=A0 =C2=A0 =C2=A0then
>=C2=A0 =C2=A0 =C2=A0 =C2=A0zle .kill-whole-line
>=C2=A0 =C2=A0 =C2=A0 =C2=A0BUFFER=3D"git d --no-pager log -1 --one= line"
>=C2=A0 =C2=A0 =C2=A0 =C2=A0zle .accept-line
>=C2=A0 =C2=A0 =C2=A0else
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0zle .accept-line
>=C2=A0 =C2=A0 =C2=A0fi
> }
>
> zle -N accept-line _check-if-dotfile-command

I currently have a directory named ~/.shell which is a git repo for all the= various . Files in my home folder (via hard links). What is the widget int= ended to do and how is it triggered?

(I realize you've moved away from this widget, but what were you trying= for).

--
=C9=B9=D7=9F=CA=87nq=D7=9F
<mailto:lbutler@= covisp.net>
tel:+1.303.219.0564




--000000000000eb1be105b2d7ffcb--