From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13652 invoked from network); 15 Jun 2000 00:25:49 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 15 Jun 2000 00:25:49 -0000 Received: (qmail 12411 invoked by alias); 15 Jun 2000 00:25:31 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 3164 Received: (qmail 12404 invoked from network); 15 Jun 2000 00:25:30 -0000 Date: Wed, 14 Jun 2000 17:25:15 -0700 (PDT) From: Bart Schaefer Sender: schaefer@aztec.zanshin.com Reply-To: Bart Schaefer To: Dominik Vogt cc: zsh-users@sunsite.auc.dk Subject: Re: '...' in path names? In-Reply-To: <20000613175417.A18345@gmx.de> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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.