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,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21521 invoked from network); 10 Feb 2021 12:45:48 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 10 Feb 2021 12:45:48 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20200801; t=1612961148; b=KlzowvFCmv9DU/eyUgTfJCawW3wV6fg/6XwdBg5pThNwxh7VuEZoiKDuRrAJgQbKVvJBLRjWto Nf9soeg3YEEmCai5YKmHUuqy64mx41CnNDLFISAP0M8O7Y1BceIHZyNPtIeuLOO+vbY5pJ8fnr uh/986Q+MRIycxbgeYQpo26xh9BXK8UCFrDSuN+OBWTGj9J7KiGet4v2crormWyFUp3pci148b v9U3SPMef75f0Xnpo3BvbNgG47fZBkgiHs0+PMF/i/DYunr0si0mNz9L6+JXipLAPV9XY87R+B t9o0ho+plWzFY4DGFTupi/Y8jh1RX48JSASCUxs6vfunOA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20200801; t=1612961148; bh=P/ZnYd7j5EX8TLSdpgarSNg6X+7/a5vweiY04MC2VJI=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=NWGBkKy0+fIcH1ILzIs8L4vfRlSvRzVOa5/PtJe6BZRZRvk4nXM8msCRioz4KgM8hrAqsH39gg 0q9YcdGT6sKxaxWYKmPApWQNkaZkMCjWink1blA/8bCKhKzQ9VH/q/UMXNM0+hgJhNFnoTJmEY jr9qB/F9w25uqrYOO9Mw0iddsKKokVc9+vFlkM0ZIlj7+L53Zn+DtybH7G/mEG8R/LPJg9gRqd xeMfDXXayJnw8ShLQfFnYSzy7tIqh7xx2lwcEJVa4KJ5+yRzmEg0msiJ5x9l+drDm53eLu3xb1 6zl1Zow9cYcoiNh0axUx+GVW2l1bHTX3NEU1tXeVF+QQDw==; 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-Transfer-Encoding: Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=F/sTvipNFE1Skex3nSAocXg0Fj00TT7eRkDXgGl5JVg=; b=p76kkr4lnGaMaJNzx+Df9aes2q uitDpCzLcbWZ9qkeIdfytQia/Q4cxj8uL3aOtFWAoCDYMsVYT43f6sqjUNc95kIbEXORYWuePXAr+ tLcizW7hWVvD12aq+vdyU10GAV5culoctvfht6JwqcKODXZVdjj+6zvx/esflXrV5IicRNDe1V9uK RxwaM0vV1dihO8f3n5ImcXGyHDU8BwJMizRMekBxscocvDYwda9XzfJhab5Dn+PJt7hvf8S5bVz63 hDb0PafGtP3O/XB9CXApR5hcnIyeWHaZ5Seu3fpyZ+Kr9+HhQgJyQ+NBPmYMQeqFSqiGK/6ZcIvtV hUFg8I+Q==; Received: from authenticated user by zero.zsh.org with local id 1l9osN-00046L-2y; Wed, 10 Feb 2021 12:45:47 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq1.tb.ukmail.iss.as9143.net ([212.54.57.96]:34312) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) id 1l9orp-0003j6-Tk; Wed, 10 Feb 2021 12:45:15 +0000 Received: from [212.54.57.81] (helo=smtp2.tb.ukmail.iss.as9143.net) by smtpq1.tb.ukmail.iss.as9143.net with esmtp (Exim 4.86_2) (envelope-from ) id 1l9orp-0002Wk-JK for zsh-users@zsh.org; Wed, 10 Feb 2021 13:45:13 +0100 Received: from oxbe20.tb.ukmail.iss.as9143.net ([172.25.160.151]) by smtp2.tb.ukmail.iss.as9143.net with ESMTP id 9orpleiQBhdRd9orpl8er2; Wed, 10 Feb 2021 13:45:13 +0100 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-users@zsh.org X-SourceIP: 172.25.160.151 X-CNFS-Analysis: v=2.4 cv=MqCXV0We c=1 sm=1 tr=0 ts=6023d559 a=Ip+kZtMD4PYul4iMASbA3A==:117 a=DeGUKtW0en8A:10 a=IkcTkHD0fZMA:10 a=zAZwVUNnDPoA:10 a=nRxgo2pvAAAA:8 a=5ctozHuC9jvMhZ0upzIA:9 a=QEXdDO2ut3YA:10 a=hyOiLu3se5BDDO0nYPa2:22 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1612961113; bh=P/ZnYd7j5EX8TLSdpgarSNg6X+7/a5vweiY04MC2VJI=; h=Date:From:To:In-Reply-To:References:Subject; b=u/zux5hD209Gxh7XUi4rXW+ImBeaID3S7rbAWvCvh2j8P1VfjuwwOzykB8KF4I5lx 9NqpO3dEuCvtAif9LtWytYqNDdUxQuVBeVqSbh3LXZTIoIcotWWxYvOxK8vL1nxeUQ GSeH9RNQP6mfdLhzv71NeSBaxx6tA1z5T9wCiAoVpW2Ux9M2voScVqXaA6WBywUCDg /9vbwVXs8MT1hHFotO9Zi696dS0VMcr5CvINlUoZ0tzWWjyp6p2yguoDCsFhapRnym LZjqCiXgegE3ny6bh/jxV1yG6N9GycMf1llS6C2SDwvnUGIow3iHhwP4zwXkaEMDu6 ULjRLRjGXsRAA== Date: Wed, 10 Feb 2021 12:45:13 +0000 (GMT) From: Peter Stephenson To: Zsh Users Message-ID: <1216298849.3722151.1612961113500@mail2.virginmedia.com> In-Reply-To: <20210210120501.GA3727@gmx.de> References: <20210210120501.GA3727@gmx.de> Subject: Re: Shortened bit branch in prompt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.8.4-Rev72 X-Originating-IP: 165.225.81.25 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfPjVShCHOuB69umUgtOXmaeW8yXsIpI7dK9eiwsSbAhe9cv2/4VDlKCBiuGCYbJTQ7rrDrPA/QU2vBLZiX7Gwl88EKYvnLh7SxgcjB3JF4WwUk/GNr+n fAt0uQp7MP4CcJKSG2PLqlg2XpJeBeo6dH6nQLIrJk0xa6b92Dj9rQ98rgtVnmBOtTlSjKMGSEkjU154xlpf2TM9OTtXrCPkyGWDYoi9H9sIL4XN3Q4m6e2G X-Seq: 26490 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: > On 10 February 2021 at 12:05 Dominik Vogt wrote: > I want to change that so > > * If the branch name is max. 25 characters, print it umodified. > * If the branch ame is loger, print > > ... > > E.g. if the branch name is abcdefghijklmnopqrstuvwxyz0123456789, > the prompt should have > > abcdefghijklmnopq...56789 > > Of course this should be done with zsh functionality only. It's possible to be completely general about printing a variable substitution based on the length, in this case of variable "foo": print ${${${${${:-$(( ${#foo} > 25 ))}##1}:-Printed if long}##0}:-Printed if short} Those arbitrary chunks are subject to further expansion, so put the expressions you need there --- in particular, $foo, ${foo[1.17]}...${foo[-5,-1]}, I haven't put those in myself just for the sake of clarity of what's going on. There are probably ways of shortening this, but by the standards of the squiggle factory that's arguably quite readable. (Only arguably.) pws