From: Bart Schaefer <schaefer@brasslantern.com>
To: Dominik Vogt <dominik.vogt@gmx.de>
Cc: zsh-users@sunsite.auc.dk
Subject: Re: '...' in path names?
Date: Wed, 14 Jun 2000 17:25:15 -0700 (PDT) [thread overview]
Message-ID: <Pine.LNX.4.20.0006141333530.14717-100000@aztec.zanshin.com> (raw)
In-Reply-To: <20000613175417.A18345@gmx.de>
On Tue, 13 Jun 2000, Dominik Vogt wrote:
> I really like to abbreviate something like '../../..' with '....'
> (you get the idea). (The last time I tried to get it working was
> zsh-3.0.5). I didn't get any farther than this:
>
> alias '...'='cd ../..'
> alias '....'='cd ../../..'
> alias '.....'='cd ../../../..'
> ...
I posted a partial solution for this in
http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=3022
> which works for '...' in the command position, but not in 'cd ...'.
Same for what I previously posted.
> Any ideas how to improve this situation?
> It would be cool if it were possible to expand strings of dots
> in every path without having to .
Without having to what?
Would you be happy enough doing this with completion, i.e. you type TAB
to expand the dots and then hit return?
------------------------------------------------------------------------
#autoload
# Put this in a file named _expand_dots in your $FPATH, then
# add _expand_dots to the front of the "completer" style, e.g:
# zstyle ':completion:*' completer _expand_dots _complete
# Requires 3.1.9.
local word sub
local patl='(#b)([^\/])..' patr='(#b)..([^\/])'
local repl='/..' repr='../'
# This first part borrowed from _expand
[[ _matcher_num -gt 1 ]] && return 1
if [[ "$funcstack[2]" = _prefix ]]; then
word="$IPREFIX$PREFIX$SUFFIX"
else
word="$IPREFIX$PREFIX$SUFFIX$ISUFFIX"
fi
# The real stuff
setopt localoptions extendedglob
sub="$word"
while [[ "$sub" = *...* ]]; do
sub="${sub/.../../..}" # Looks odd because the 3rd / isn't magic
done
sub="${sub//$~patl/$match[1]$repl}"
sub="${sub//$~patr/$repr$match[1]}"
[[ "$sub" != "$word" ]] && compadd -QU -S '' "$sub"
------------------------------------------------------------------------
If you prefer not to have it expand the dots unless there's a real file or
directory to match, you can change that last line to something like
[[ "$sub" != "$word" && -r "$sub" ]] && compadd -QU -S '' "$sub"
but that may cause undesired effects e.g. for completion along $cdpath.
prev parent reply other threads:[~2000-06-15 0:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-06-13 15:54 Dominik Vogt
2000-06-15 0:25 ` Bart Schaefer [this message]
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=Pine.LNX.4.20.0006141333530.14717-100000@aztec.zanshin.com \
--to=schaefer@brasslantern.com \
--cc=dominik.vogt@gmx.de \
--cc=zsh-users@sunsite.auc.dk \
/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).