Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Completion on dots
- X-seq: zsh-users 16258
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Jesper Nygårds <jesper.nygards@xxxxxxxxx>
- Subject: Re: Completion on dots
- Date: Wed, 17 Aug 2011 16:59:50 +0200
- Cc: zsh-users@xxxxxxx
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=UuCD21Sjj2m6trKWEsO+630M2luZjbr7vcYKgupHMLI=; b=DVNUhyU83Ab8LW9dBLym9g12acEURK0i5gnasukjNRcxLYTap+h/Ubn8B/5U2n0DeW O7mnxneo4fRgYIZJa1CPL2nZ+8BMRQZTIlEJMffARcsHG2n2hYqV3B7ojyAR/Lflpk2C IUbO7X0VZH+ENjHAv4YZZg9BXcfexHL4FeykI=
- In-reply-to: <CABZhJg-9pDnWzsJLqGjOZNfZZL6Z0OSFArg3ddV1YpFy3gjOFA@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CABZhJg-9pDnWzsJLqGjOZNfZZL6Z0OSFArg3ddV1YpFy3gjOFA@mail.gmail.com>
2011/8/17 Jesper Nygårds <jesper.nygards@xxxxxxxxx>:
> 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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author