From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-users@zsh.org
Subject: Re: alias hygiene
Date: Tue, 27 Feb 2018 14:48:58 +0100 [thread overview]
Message-ID: <20180227134858.GB10630@cventin.lip.ens-lyon.fr> (raw)
In-Reply-To: <1518881445.3606980.1274127384.7D7A2004@webmail.messagingengine.com>
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 <vincent@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)
next prev parent reply other threads:[~2018-02-27 13:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-14 16:09 Ray Andrews
2018-02-17 0:30 ` Daniel Shahaf
2018-02-17 3:14 ` Ray Andrews
2018-02-17 13:54 ` Daniel Shahaf
2018-02-17 15:20 ` Ray Andrews
2018-02-17 15:30 ` Daniel Shahaf
2018-02-17 15:42 ` Ray Andrews
2018-02-17 22:04 ` Bart Schaefer
2018-02-18 0:17 ` Ray Andrews
2018-02-18 2:10 ` Bart Schaefer
2018-02-18 3:38 ` Ray Andrews
2018-02-19 6:37 ` Bart Schaefer
2018-02-27 13:48 ` Vincent Lefevre [this message]
2018-02-27 15:26 ` Ray Andrews
2018-02-17 15:36 ` Daniel Shahaf
2018-02-17 21:40 ` Bart Schaefer
2018-02-18 0:08 ` Ray Andrews
2018-02-19 6:28 ` Bart Schaefer
2018-02-19 18:14 ` Ray Andrews
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180227134858.GB10630@cventin.lip.ens-lyon.fr \
--to=vincent@vinc17.net \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).