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,NICE_REPLY_A, RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 3475 invoked from network); 11 Aug 2021 06:25:52 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 11 Aug 2021 06:25:52 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1628663152; b=qPzkMkHSB3blIeEW78Sg/Zk4GSuK9USG0kuRTKrgTXF4v6RYpYZ9C5Gbs7rEXaQ32AG+74RBdR GtniVwslawmqeaqv5pL63e6zRNR+kGpbHzRvL40eAIKfo/H0alnRUy1xY2Q/DLeIxUZ+6OZJZJ OUt6dV2s6dqjPDNgOGV4v0q7B7Wc8liq73in4TQwTutRtYmhz2P/AAnUbF24V+MYG7G4gB84Ab WDe8C7sZW7j8u3AW7eWwCYcYvusMjsxa8R/NifesMCgUKn4d9zEGogjw5aMKaOCYhGV3/wzxGw HYuFFIAHn66l3ZYjsXGJYRyyrom9+h8IpTMPjJ+AM1oTGw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f48.google.com) smtp.remote-ip=209.85.167.48; 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-20210803; t=1628663152; bh=S6e9iuRVvwHSS+/yPjSMjoKSl08RxXHHMpnLxz94FN0=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:In-Reply-To: MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:DKIM-Signature: DKIM-Signature; b=GwF9ROO1X98XXc/6ei6V0riI4lmnwn1qzeC3BwxddvdmmdN42oiQ1IrdaDkVofViv9sHKmjtUm lxusy/75O7ho85IUnNZt7gMLwWMoQpDry7ekQfaq4C22oWEuQp6+OJr2ayG9KtlSxDmnJlSJ60 cRalVq5nNRyf1bUBtr0wkFt9IZM218CHuTNBZB4ypfAExyAHUVkJYirh4hlfuxS7AaEJgAJyGD Ti0QKNc3YoPt0uyqTSylVVqcPnjxM+hZdy8WP/jTRy3r8RnZmzZxzNulsL2GRrgSqdxy8ZpE15 hvwzs2O7UbHr7NRU2CmSLtW7UPLaGRYBD7jahf+/AyApHw==; 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-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=aG+EBot2jGuH2+SeigSymaHKuZM+LZdM9ZwDe+i1hMc=; b=Nmri/uCLTRXFeSVAMnTFsyIL6M yId+RF6mSohuwJp90mrnJ20NNsQDWCa1xnnPJSh1XhV/WVhKhfdSRSYl0hKe6l1grrq7Upc0SVze1 Qu1mBeQjJfssby9ZVeNPmSZPdHcz63DXCNacNx5WjPDiOFlQUV15lDGxTkyi6/EBuuKw6wmW4zVg1 ym1DdC5KOeElGtOaT4TE2vdcIxMct2o8buExFQsBFr6VO3Q2HzGazrXNGm6vIAWo8AV2CbUh0/lpO AzkWYMB50BYIQUGxSKHslj7mN+DlT76AEgN3RlcZkKcXWqjs2KbTOVAA8oEBnTBgThrbkEtHlAOzK 9ZiTOD4w==; Received: from authenticated user by zero.zsh.org with local id 1mDhgV-0008vo-Oy; Wed, 11 Aug 2021 06:25:51 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f48.google.com) smtp.remote-ip=209.85.167.48; dkim=pass header.d=gmail.com header.s=20161025 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lf1-f48.google.com ([209.85.167.48]:39842) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mDhfR-0008BW-5X; Wed, 11 Aug 2021 06:24:45 +0000 Received: by mail-lf1-f48.google.com with SMTP id t9so3367333lfc.6 for ; Tue, 10 Aug 2021 23:24:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=aG+EBot2jGuH2+SeigSymaHKuZM+LZdM9ZwDe+i1hMc=; b=sjg07YHKocOASw46rn2SsWIoY24hYM3qZVUDvTxB34VvNl0qQ8tviNy+TvpVj0jZQs sp6hpZO1OwhFOPWvNiMY9Ybo8QOk5XuQZ443tKHLGUcXdXjiN0RlBf2ABElMyfzwpykP Af3XdQiBp2JcAQwxcHU4bm+TuaI0TE8xGtVqGdqlOZ8k4G0058Azb9iKtF+VTPSeb7IL IiJ+N9Zdx5r40yDkaLyjiIZCZIz89hCX4yG+34alzQbZ/Wf+qIxLf5rnLHk32hqaVuDL /Pe7oh7dTd7EAEzuR/sPRVjx0nAnFQ8i79KQxZHFlkzIq3Zuu/PYvamrVgWeAmMXWnoj G6UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=aG+EBot2jGuH2+SeigSymaHKuZM+LZdM9ZwDe+i1hMc=; b=kIaV96dUkKhMwBXAFvdr20eE4IsHtdkzObGjWG+NMLOXiO+KEc9GyJQbKlR+6ZcNtL BvUbj7fJ1CwyDOuGf/nLn0HQ/q1AZDLxaJmehBE1AujKED6OIzA6Rs1zdiSLD33Mr9Ti CbALZbZsQg+7Zee6YyjIECU75w8WOMgCwlfdY1RXR31DcyUPEngoMb3vdZ4KuQcEekWf cFpFLp6EeqrpiENOAJtQuansuhvQ8ghl7Z3Rwce/7HYuRnzy+w3mRbDtT5tVVb/ua+Ty LJ+1vlOLmN6YEK4HkHc/Iz3KjUUNE42Vu67OlzbeLn2KXwDp9OOwofJWHIfl36xt/7RN HmPw== X-Gm-Message-State: AOAM5323wBKQR/bG//wjmJtutgnP9lP2E+Q1ExOTwrUkFbRRZ8nnqsR/ +59ZMHliRsctBTP+kkM48RKb/WaBFGuEfw== X-Google-Smtp-Source: ABdhPJzwnWNSbUWdhsIXorMRRBi929+XB2fFVYrCRw2/VLH3814116r1094LGGLJW0hNm5FEMBf7dg== X-Received: by 2002:a19:f016:: with SMTP id p22mr25199143lfc.56.1628663084303; Tue, 10 Aug 2021 23:24:44 -0700 (PDT) Received: from ?IPv6:2001:16b8:68e7:7e00:adf0:65ea:719d:c2e5? (200116b868e77e00adf065ea719dc2e5.dip.versatel-1u1.de. [2001:16b8:68e7:7e00:adf0:65ea:719d:c2e5]) by smtp.gmail.com with ESMTPSA id i9sm2259380lfo.21.2021.08.10.23.24.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Aug 2021 23:24:43 -0700 (PDT) Subject: Re: Converting relative paths to full To: Bart Schaefer Cc: Zsh Users References: <68cd3b1c-0a75-af79-f262-e5dd32233c55@gmail.com> <3c2e9d50-b7c5-6e59-c29f-3d175e7bf608@gmail.com> From: =?UTF-8?Q?G=c3=bcrkan?= Message-ID: <24f91d99-bedb-3fd1-2282-7ecddde432b6@gmail.com> Date: Wed, 11 Aug 2021 08:24:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Seq: 26909 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: On 11/08/2021 00.36, Bart Schaefer wrote: > That's far more complicated than necessary. > > function _edit_command_to_register_full_path { > emulate -L zsh > for element in ${(z)1}; do > # Don't care about parameters > [[ $element == -* ]] && continue > FULLPATH="${element:P}" > # Don't replace when already the full path > [[ $element == $FULLPATH ]] && continue > # Don't replace when path doesn't exist > [[ -f $FULLPATH || -d $FULLPATH ]] || continue > # [[:space:]] to protect previous replacements > # (this is still not foolproof for path prefixes) > set -- "${1/[[:space:]]$element/ $FULLPATH}" > done > print -Sr -- ${1%%$'\n'} > return 1 > } Thank you, that looks indeed much better. I am still potato on shell builtins topic, will read and try to shorten my 400-line rc file :)