From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29075 invoked by alias); 27 Feb 2018 13:49:09 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23181 Received: (qmail 16536 invoked by uid 1010); 27 Feb 2018 13:49:09 -0000 X-Qmail-Scanner-Diagnostics: from cventin.lip.ens-lyon.fr by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(140.77.13.17):SA:0(-1.9/5.0):. Processed in 7.520007 secs); 27 Feb 2018 13:49:09 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: vincent@vinc17.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Date: Tue, 27 Feb 2018 14:48:58 +0100 From: Vincent Lefevre To: zsh-users@zsh.org Subject: Re: alias hygiene Message-ID: <20180227134858.GB10630@cventin.lip.ens-lyon.fr> Mail-Followup-To: zsh-users@zsh.org References: <1679a1e0-f716-e501-c4c2-f7e485f9701f@eastlink.ca> <1518827410.2159479.1273706656.1F5B436D@webmail.messagingengine.com> <37bb7b6b-ad70-6d03-f979-0e0d3b0be4d3@eastlink.ca> <1518875676.3562728.1274073304.5ED24DC8@webmail.messagingengine.com> <20f1c297-7c7d-109f-b9ee-b53823aa476c@eastlink.ca> <1518881445.3606980.1274127384.7D7A2004@webmail.messagingengine.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1518881445.3606980.1274127384.7D7A2004@webmail.messagingengine.com> X-Mailer-Info: https://www.vinc17.net/mutt/ User-Agent: Mutt/1.9.3+93 (ebd93b50) vl-105418 (2018-02-14) On 2018-02-17 15:30:45 +0000, Daniel Shahaf wrote: > Ray Andrews wrote on Sat, 17 Feb 2018 07:20 -0800: > > Thanks.  There's a lot of homework in your post, I'll get on it. For now > > I take it that one can legitimately have an alias definition conditional > > on some test, at least in theory, > > Yes. Example: > > case $OSNAME in > (linux*) alias ls='ls --color';; > (freebsd*) alias ls='ls -G';; > esac And I even have an alias generator that can redefine existing aliases: use-pager() { local -a cmd cmd=(pager-wrapper) while [[ $1 == -* ]] do cmd+=${(q)1} shift done local i for i in $@ do whence $i > /dev/null && alias $i="$cmd ${(Q)"${$(alias $i)#*=}":-$i}" done } I hope that's correct. The goal is to alias commands to use a pager when possible (the pager-wrapper function uses a pager only when the output is sent to a terminal). -- Vincent Lefèvre - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)