zsh-users
 help / color / mirror / code / Atom feed
* Completion on dots
@ 2011-08-17 14:40 Jesper Nygårds
  2011-08-17 14:50 ` Magnus Woldrich
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Jesper Nygårds @ 2011-08-17 14:40 UTC (permalink / raw)
  To: zsh-users

I have the following in my .zshrc:

alias -g ...='../../'

which of course allows me to write for example "ls ..." to show all
files in the grand-parent directory.

However, it doesn't work with completion: I can't write "ls
.../<TAB>", and have zsh complete on the available files in the
grand-parent directory.

Would it be possible to write such a completion function? And ideally,
for even more dot patterns: "...", "...." etc, to continue up in the
file hierachy?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Completion on dots
  2011-08-17 14:40 Completion on dots Jesper Nygårds
@ 2011-08-17 14:50 ` Magnus Woldrich
  2011-08-17 14:58 ` Manuel Presnitz
  2011-08-17 14:59 ` Mikael Magnusson
  2 siblings, 0 replies; 5+ messages in thread
From: Magnus Woldrich @ 2011-08-17 14:50 UTC (permalink / raw)
  To: zsh-users

On 2011-08-17 16:40, Jesper Nygårds wrote:
>I have the following in my .zshrc:
>
>alias -g ...='../../'
>
>However, it doesn't work with completion: I can't write "ls
>.../<TAB>", and have zsh complete on the available files in the
>grand-parent directory.

Try this:

     setopt complete_aliases

-- 
│ Magnus Woldrich
│ m@japh.se
│ http://japh.se


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Completion on dots
  2011-08-17 14:40 Completion on dots Jesper Nygårds
  2011-08-17 14:50 ` Magnus Woldrich
@ 2011-08-17 14:58 ` Manuel Presnitz
  2011-08-17 14:59 ` Mikael Magnusson
  2 siblings, 0 replies; 5+ messages in thread
From: Manuel Presnitz @ 2011-08-17 14:58 UTC (permalink / raw)
  To: "Jesper Nygårds", zsh-users

Unfortunately I cannot answer your question, but there was a really neat funtion posted some month ago: http://www.zsh.org/mla/users/2010/msg00770.html

Perhaps that's an alternative for you, too!



-------- Original-Nachricht --------
> Datum: Wed, 17 Aug 2011 16:40:02 +0200
> Von: "Jesper Nygårds" <jesper.nygards@gmail.com>
> An: zsh-users@zsh.org
> Betreff: Completion on dots

> I have the following in my .zshrc:
> 
> alias -g ...='../../'
> 
> which of course allows me to write for example "ls ..." to show all
> files in the grand-parent directory.
> 
> However, it doesn't work with completion: I can't write "ls
> .../<TAB>", and have zsh complete on the available files in the
> grand-parent directory.
> 
> Would it be possible to write such a completion function? And ideally,
> for even more dot patterns: "...", "...." etc, to continue up in the
> file hierachy?

-- 
NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie!		
Jetzt informieren: http://www.gmx.net/de/go/freephone


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Completion on dots
  2011-08-17 14:40 Completion on dots Jesper Nygårds
  2011-08-17 14:50 ` Magnus Woldrich
  2011-08-17 14:58 ` Manuel Presnitz
@ 2011-08-17 14:59 ` Mikael Magnusson
  2011-08-18  5:52   ` Jesper Nygårds
  2 siblings, 1 reply; 5+ messages in thread
From: Mikael Magnusson @ 2011-08-17 14:59 UTC (permalink / raw)
  To: Jesper Nygårds; +Cc: zsh-users

2011/8/17 Jesper Nygårds <jesper.nygards@gmail.com>:
> I have the following in my .zshrc:
>
> alias -g ...='../../'
>
> which of course allows me to write for example "ls ..." to show all
> files in the grand-parent directory.
>
> However, it doesn't work with completion: I can't write "ls
> .../<TAB>", and have zsh complete on the available files in the
> grand-parent directory.
>
> Would it be possible to write such a completion function? And ideally,
> for even more dot patterns: "...", "...." etc, to continue up in the
> file hierachy?

.../ isn't an alias, so it won't work. ls .../foo will also not work,
regardless of completion. This is a better solution,

# just type '...' to get '../..', then additional . adds more /.. segments
_rationalise-dot() {
  local MATCH
  if [[ $LBUFFER =~ '(^|/| |	|'$'\n''|\||;|&)\.\.$' ]]; then
    LBUFFER+=/
    zle self-insert
    zle self-insert
  else
    zle self-insert
  fi
}
zle -N _rationalise-dot
bindkey . _rationalise-dot
# without this, typing a . aborts incremental history search
bindkey -M isearch . self-insert


-- 
Mikael Magnusson


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Completion on dots
  2011-08-17 14:59 ` Mikael Magnusson
@ 2011-08-18  5:52   ` Jesper Nygårds
  0 siblings, 0 replies; 5+ messages in thread
From: Jesper Nygårds @ 2011-08-18  5:52 UTC (permalink / raw)
  To: zsh-users

Thanks for that, it works great!


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-18  5:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-17 14:40 Completion on dots Jesper Nygårds
2011-08-17 14:50 ` Magnus Woldrich
2011-08-17 14:58 ` Manuel Presnitz
2011-08-17 14:59 ` Mikael Magnusson
2011-08-18  5:52   ` Jesper Nygårds

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).