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 15776 invoked from network); 18 May 2022 22:43:36 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 18 May 2022 22:43:36 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1652913816; b=Za5LYqDW/VqIvCzd9IGKF8jvd/mf1/dMTtEdAMcykj27keGM2nzHHImENQzf1DZ4mVJ3lxNUwn bKZCvEIfnPonY275iTLOWOh+mg/YfooKPy4cyhLY1UqbqMpNZSuc2GI+drd+FI/hSNgzzo7sNX N8+hX2ZPXNGYLWkGgWQ093hkHl4Kym8YWSLcWCARaKpJSPRMwOjTRqhdeYBZnZ3VOueu6oJhgN 6xCASE/fkzG937GUERXIGeRQVkjhKsQyF1dws04VZ4E62XZSykC2ylJJLC+OoMpdX7lnKYvPgn TaTb9a0zxqrT1wMuhf6YJaHOl9C5RMW6mvHWZzseayHbqg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wr1-f41.google.com) smtp.remote-ip=209.85.221.41; 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=1652913816; bh=okLI2xgDrMjcRq4hv4EcyAmJv0oH3iTreG1wa+F1zTs=; 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=TwSm3msg3xVjEEqn0c0ACyCpgMWdDWCtbC9M4rQ4Z8OjjZYjF1+iqhM43cjmK8OWwZsNWwXJV6 8/u3pW8SsEvhVIh3O9hYRiFSdk9YsEDwG0+DROB9Cz4Lj720BSSln6JdgDGwn1KIU/PfUygPcV UIfnSr0Li7r4drwRFfTXLdvniNJnGOvaCloFIjFIfgZINFXQTc35EDLAIjDuzJveoRMyIOBTJu DejWxl0F5JI1anfL8M/gNcJGq9y5Q+Ub+kFo4Ge/y86Cn6Rluo5BpSUQMu3Jd3o4AsuXZnM51D IcNuzro22mEI5nMJE6sM52nNaJy3S6Hv9U6eOcxmHSrR0Q==; 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=0Pe9CKVLQ0SEgPf9LVJ9sv7T+zXamAhBjp6I8cNngFI=; b=YeNf5PT6pJWuitAEA8kcC3Hr/L 2afn10lBqAynF7lhbt8kahI2sHXu7A/dPG8IzJh1njAxk+7SWhw1Kvacj+9qhUw6Wcu1t9jqEwiNu pyglPxhM6vSDSpkrXI+zqG5DmTakDDOpnHLMPdXUzKTYii0VGID9fafFX5lGnTUkt6127FnyC/orq B2FZqZD7G1B130NlJHwxQu/JebxV3I3mwZ5Q6eMOXhJa3Ty3rKCxgcyYCU9bs1qFkTZhhhkLHUWtH 3mnEvzWOmL/0dXyLCW+u1yDedbA8oh2uRtFyecOkU9sBEUYQZIYRr/MJSCioLlDAO0Xhtb/JPFlfL 29kIGUPw==; Received: from authenticated user by zero.zsh.org with local id 1nrSOE-0002TU-PN; Wed, 18 May 2022 22:43:34 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wr1-f41.google.com) smtp.remote-ip=209.85.221.41; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-wr1-f41.google.com ([209.85.221.41]:40700) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1nrSNL-0001lF-1D; Wed, 18 May 2022 22:42:39 +0000 Received: by mail-wr1-f41.google.com with SMTP id s28so4530949wrb.7 for ; Wed, 18 May 2022 15:42:38 -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=0Pe9CKVLQ0SEgPf9LVJ9sv7T+zXamAhBjp6I8cNngFI=; b=cGNfrkPGH6O5qaKP71XXlx42W4fdnv6HB3Wjt3g3+0h36dyxhs9gQupt85iqQ8lnAp x2Eao/M02+d8ipuo1eIgKFEGxaaFLzzBn4Wio0nDEHCVghd9bn2hp1F8SdiAgNtkczbY lxJUkqADMsGUz4w58HoL6IQC2iSqWt6KlMWGH1lSoJHAsy5JHz2rkjVnD6V9+h/hBlYT +AbKA9qLCLl6LavTuMquTnns4UCljm02bvvhPnexOXhSI2wMRu67IR4NoAzFam2NiaOu xbKooq5NYX0lQDRvMjLXmxDc3AJ2tc6DQYxk85Gu/cZoOPXV2EqazMaS3vIbB+i3YX09 Y6eg== 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=0Pe9CKVLQ0SEgPf9LVJ9sv7T+zXamAhBjp6I8cNngFI=; b=o0vz4E+dTHcuOYo7YQf5rZroTvdEpu87JkQgLAadNVFtSlBMjBdVrgff2FlrPVwZa6 QWVXW9k0GAMqzXwof2bCqoGUuvr5eNzpnoFgpZPtXidI7+kscm9ZhYAPN8QiyVx6V9vf 4W+nRP3EPwpae9zf3u/IQKjTck7I7yrICGukAQJEEP5oQxMjdyQphKscTgyT9wsXpnm8 PoN5SyjUh44cimEUTEqSkGOabutzZjAUEaoxCTcKwl+414L4zfD0fHNhMwlPWgR3Mgj/ iOkpY5Cs9cL70dzhdFj4CgeunJqqI7jrS61hNoONZuy/ycvYHlLSCMkuFi8wFgpx5JQg Myow== X-Gm-Message-State: AOAM531RCV5pStc4Arn2B+aH1aN6gAu90cUamA1Hbe0far0TMd7ovzTC yFV4LTD0vSPD1C3m8JnLsaA7dXCPvPOvGMeQ6jk= X-Google-Smtp-Source: ABdhPJzBhNpoNWiaZgoNUy87jUC++lEy5MBvovhc4AHqeWycUOHR+p6Vl4f2uCSLkFvYG0l6pNUewFLLt3U8m4XnMQk= X-Received: by 2002:adf:f8c9:0:b0:20d:11ae:d104 with SMTP id f9-20020adff8c9000000b0020d11aed104mr1476517wrq.89.1652913758414; Wed, 18 May 2022 15:42:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Zach Riggle Date: Wed, 18 May 2022 17:42:27 -0500 Message-ID: Subject: Re: Collapse a file path to the shortest representation To: Mikael Magnusson Cc: Zsh Users Content-Type: multipart/alternative; boundary="0000000000006a2f2405df50f982" X-Seq: 27766 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: --0000000000006a2f2405df50f982 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks! It does indeed. Is there a way to specify appearance? ~ENV vs $ENV ~SOME_ENV_VAR/foo/bar $SOME_ENV_VAR/foo/bar *Zach Riggle* On Fri, May 13, 2022 at 1:03 PM Mikael Magnusson wrote: > On 5/13/22, Zach Riggle wrote: > > Is there a ZSH standard way to collapse a file path to its shortest > > representation that would be idempotent per Chapter 14.7? > > > > For example, one might > > > > echo "$filepath" | sed -E "s|$HOME/?|~/|" > > echo "$filepath" | sed -E "s|$HOME/?|\$HOME/|" > > > > > > In order to turn > > > > /home/username/bar/baz =E2=86=92 ~/bar/baz > > /home/username/bar/baz =E2=86=92 $HOME/bar/baz > > > > > > To achieve this effect. > > > > From the documentation, "14.7 Filename Expansion" has a lot of ways tha= t > > paths can be expanded, including... > > > > 14.7.2 > > ... the path is checked to see if it has a named directory as its prefi= x. > > If so, then the prefix portion is replaced with a =E2=80=98~=E2=80=99 f= ollowed by the > name > > of the directory .... > > > > > > Is there a standardized way to access this expansion with e.g. > > /path/to/somedir =E2=86=92 ~SOMEDIR/foo? > > The D parameter expansion flag does this. > > -- > Mikael Magnusson > --0000000000006a2f2405df50f982 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Thanks! It does indeed.

Is there a way = to specify appearance?=C2=A0 ~ENV vs $ENV

=C2=A0 = =C2=A0 =C2=A0 =C2=A0 ~SOME_ENV_VAR/foo/bar
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 $SOME_ENV_VAR/foo/bar

Zach Riggle


On Fri, May 13, 2022 at 1:03 PM Mikael Magnusson <mikachu@gmail.com> wrote:
On 5/13/22, Zach Riggle = <zachriggle@gm= ail.com> wrote:
> Is there a ZSH standard way to collapse a file path to its shortest > representation that would be idempotent per Chapter 14.7?
>
> For example, one might
>
> echo "$filepath" | sed -E "s|$HOME/?|~/|"
> echo "$filepath" | sed -E "s|$HOME/?|\$HOME/|"
>
>
> In order to turn
>
> /home/username/bar/baz =E2=86=92 ~/bar/baz
> /home/username/bar/baz =E2=86=92 $HOME/bar/baz
>
>
> To achieve this effect.
>
> From the documentation, "14.7 Filename Expansion" has a lot = of ways that
> paths can be expanded, including...
>
> 14.7.2
> ... the path is checked to see if it has a named directory as its pref= ix.
> If so, then the prefix portion is replaced with a =E2=80=98~=E2=80=99 = followed by the name
> of the directory ....
>
>
> Is there a standardized way to access this expansion with e.g.
> /path/to/somedir =E2=86=92 ~SOMEDIR/foo?

The D parameter expansion flag does this.

--
Mikael Magnusson
--0000000000006a2f2405df50f982--