* Tab Expanding Global Aliases
@ 2014-02-04 18:10 zzapper
2014-02-04 19:34 ` Bart Schaefer
2014-02-04 23:52 ` Oliver Kiddle
0 siblings, 2 replies; 8+ messages in thread
From: zzapper @ 2014-02-04 18:10 UTC (permalink / raw)
To: zsh-users
Hi
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?
I am using http://zshwiki.org/home/examples/zleiab as an alternative
--
zzapper
https://twitter.com/dailyzshtip
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tab Expanding Global Aliases
2014-02-04 18:10 Tab Expanding Global Aliases zzapper
@ 2014-02-04 19:34 ` Bart Schaefer
2014-02-04 20:43 ` zzapper
2014-02-04 23:52 ` Oliver Kiddle
1 sibling, 1 reply; 8+ messages in thread
From: Bart Schaefer @ 2014-02-04 19:34 UTC (permalink / raw)
To: zsh-users
On Feb 4, 6:10pm, 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?
There's not only no reason, it's already supported.
zstyle ':completion:*' completer _expand_alias _expand _complete _ignored
Augmented with e.g.
zstyle ':completion:*:expand-alias:*' disabled yes
if you want to expand aliases with tab that would otherwise not expand.
(I haven't actually tried that ...)
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tab Expanding Global Aliases
2014-02-04 18:10 Tab Expanding Global Aliases zzapper
2014-02-04 19:34 ` Bart Schaefer
@ 2014-02-04 23:52 ` Oliver Kiddle
2014-02-05 13:11 ` zzapper
1 sibling, 1 reply; 8+ messages in thread
From: Oliver Kiddle @ 2014-02-04 23:52 UTC (permalink / raw)
To: zsh-users
[-- 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tab Expanding Global Aliases
2014-02-04 23:52 ` Oliver Kiddle
@ 2014-02-05 13:11 ` zzapper
2014-02-05 13:48 ` Oliver Kiddle
0 siblings, 1 reply; 8+ messages in thread
From: zzapper @ 2014-02-05 13:11 UTC (permalink / raw)
To: zsh-users
Oliver Kiddle <okiddle@yahoo.co.uk> wrote in
news:6788.1391557936@quattro:
> 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'
>
I can get this to work but only if I begin the 'abbreviation' with I ???
--
zzapper
https://twitter.com/dailyzshtip
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Tab Expanding Global Aliases
2014-02-05 13:11 ` zzapper
@ 2014-02-05 13:48 ` Oliver Kiddle
2014-02-05 14:50 ` zzapper
0 siblings, 1 reply; 8+ messages in thread
From: Oliver Kiddle @ 2014-02-05 13:48 UTC (permalink / raw)
To: zsh-users
zzapper wrote:
> Oliver Kiddle <okiddle@yahoo.co.uk> wrote in
> > 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'
> >
> I can get this to work but only if I begin the 'abbreviation' with I ???
There was a mistake in my example using a backslash. It should be, e.g.:
bindkey -s '\\m' "(#qu$EUID)"
You also have to be fairly fast if you've set KEYTIMEOUT low.
Oliver
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-02-05 15:04 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-04 18:10 Tab Expanding Global Aliases zzapper
2014-02-04 19:34 ` Bart Schaefer
2014-02-04 20:43 ` zzapper
2014-02-04 23:52 ` Oliver Kiddle
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
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).