zsh-users
 help / color / mirror / code / Atom feed
From: Oliver Kiddle <okiddle@yahoo.co.uk>
To: zsh-users@zsh.org
Subject: Re: Tab Expanding Global Aliases
Date: Wed, 05 Feb 2014 00:52:16 +0100	[thread overview]
Message-ID: <6788.1391557936@quattro> (raw)
In-Reply-To: <XnsA2CAB8DFCBF10davidrayninfocouk@80.91.229.13>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1337 bytes --]

zzapper wrote:
> I guess this must be an old chestnut for this NG.
> But is there any reason why global aliases are not/could be tab expandable?

With global aliases, it is always worth considering using bindkey -s
instead. This expands the string immediately without needing a tab or
space.

So for example:
  bindkey -s 'Im' '| more'

It is then more important to choose combinations that you won't really
want to type. I used to prefix them with the ¬ that's on a UK keyboard
but I don't use a UK keyboard anymore.

An advantage of bindkey -s is that they can be used as abbreviations for
things that appear in the middle of a string. Common glob qualifiers,
for example:
  bindkey -s '\m' "(#qu$EUID)"
  bindkey -s '\p' '(../)##'

Given how popular global aliases for piping to the pager are, I'm
surprised we don't have a PIPENULLCMD. I'm guessing it is because the
shell has always allowed you to continue on a new line after a pipe but
maybe that isn't so important in an interactive shell.

The following works. You can still use |\ if you want continuation. Can
anyone foresee a problem with using it?  Any ideas on improvements such as
making the pager not appear in the history or on the terminal?
  zle-line-init () {
    local state=${(%):-%_}
    [[ $state = pipe && $PREBUFFER != *\\? ]] && zle -U $'less\n'
  }

Oliver


  parent reply	other threads:[~2014-02-04 23:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-04 18:10 zzapper
2014-02-04 19:34 ` Bart Schaefer
2014-02-04 20:43   ` zzapper
2014-02-04 23:52 ` Oliver Kiddle [this message]
2014-02-05 13:11   ` zzapper
2014-02-05 13:48     ` Oliver Kiddle
2014-02-05 14:50       ` zzapper
2014-02-05 15:04         ` Peter Stephenson

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=6788.1391557936@quattro \
    --to=okiddle@yahoo.co.uk \
    --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).