zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Marlon <marlon.richert@gmail.com>
Cc: Mikael Magnusson <mikachu@gmail.com>,
	Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Rewrite of zsh-newuser-install (Mikael's subthread)
Date: Wed, 7 Apr 2021 15:14:06 +0000	[thread overview]
Message-ID: <20210407151406.GA6316@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <E9B97A4D-3406-449E-86FD-6CC5DFC21935@gmail.com>

Marlon wrote on Wed, Apr 07, 2021 at 17:28:29 +0300:
> On 5. Apr 2021, at 22.44, Mikael Magnusson <mikachu@gmail.com> wrote:
> > On 4/5/21, Marlon Richert <marlon.richert@gmail.com> wrote:
> >> # Use suffix aliases to associate file extensions with commands.
> >> # This way, you can open a file simply by typing its name.
> >> # See http://zsh.sourceforge.net/Doc/Release/Shell-Builtin-Commands.html#index-alias
> >> READNULLCMD='less'      # Makes `< foo` do `less < foo`.
> >> alias -s txt='<' md='<' # .txt and .md files
> >> alias -s log='tail -f'  # .log files
> > 
> > Letting the user type < for less is one thing, but you don't really
> > save anything by using a shorter command in the rhs of an alias... it
> > does doesn't allow the user to type more than one filename. eg:
> > % < file1 file2
> > zsh: command not found: file2
> > % less file1 file2
> > file1 (file 1 of 2) lines ?-?/? (END) - Next: file2
> 
> There’s no harm in it, though, is there?

Use of identifiers that consist of punctuation only makes the code more
difficult to read / understand / look up.  For instance, given the
documentation of «alias -s», a new user might look up a «<» command in
the index.

> Plus it makes it so you Don’t Repeat Yourself. Now you have only
> variable you need to change when you want to move from `less` to, say,
> `bat`.

There's a clearer way to do that:

    alias -s txt='$READNULLCMD'

or, to mimic the built-in semantics of $READNULLCMD falling back to $NULLCMD:

    alias -s txt='${READNULLCMD:-${NULLCMD}}'



  reply	other threads:[~2021-04-07 15:14 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-05 19:44 Mikael Magnusson
2021-04-05 21:01 ` Mikael Magnusson
2021-04-05 21:44 ` Bart Schaefer
2021-04-07 13:44   ` Marlon
2021-04-07 16:24     ` Daniel Shahaf
2021-04-10 11:23       ` Marlon
2021-04-10 20:46         ` dana
2021-04-10 21:41           ` Bart Schaefer
2021-04-10 22:03             ` Roman Perepelitsa
2021-04-11 11:38               ` Marlon Richert
2021-04-13 14:49               ` Daniel Shahaf
2021-04-13 14:55           ` Daniel Shahaf
2021-04-07 14:28 ` Marlon
2021-04-07 15:14   ` Daniel Shahaf [this message]
2021-04-07 16:36   ` Bart Schaefer
2021-04-07 18:15   ` Mikael Magnusson
2021-04-07 18:50     ` Daniel Shahaf
2021-04-07 20:08     ` Arseny Maslennikov
2021-04-09 20:07     ` Marlon
2021-04-09 22:04       ` Oliver Kiddle
2021-04-09 23:04         ` Daniel Shahaf
2021-04-09 23:55           ` Bart Schaefer
2021-04-13 15:00             ` Daniel Shahaf
2021-04-09 23:08         ` Bart Schaefer
2021-04-10  7:44           ` Roman Perepelitsa
2021-04-09 23:23       ` Mikael Magnusson
2021-04-10  7:45         ` Marlon Richert
2021-04-09 15:29   ` Marlon

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=20210407151406.GA6316@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=marlon.richert@gmail.com \
    --cc=mikachu@gmail.com \
    --cc=zsh-workers@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).