zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: Why doesn't tab expand .
Date: Wed, 11 Oct 2006 09:38:37 -0700	[thread overview]
Message-ID: <061011093837.ZM18049@torch.brasslantern.com> (raw)
In-Reply-To: <Xns9859680C8852Fzzappergmailcom@80.91.229.5>

On Oct 11,  9:13am, zzapper wrote:
}
} zzapper <david@tvis.co.uk> wrote in news:Xns9857CE0FC8AA4zzappergmailcom@
} 80.91.229.5:
} 
} > cp /tmp/fred.txt .<Tab>
} expanding to:-
} > cp /tmp/fred.txt fred.txt
} 
} Which I could then arbitrarily choose to modify.
} 
} Someone has pointed out that . means current directory, so I guess it
} would be imoral

Well, not immoral, just ambiguous.  You have to assert via zstyles or
compdef that "." should not be considered a valid completion by itself,
and then assert by an entry in the matcher-list zstyle that it's OK to
complete both sides around a dot without having any other clues.

Although ... it looks like specifically what you want is not for "."
to complete, but for "cp" completion to insert the tail of the source
path argument as the default target argument?

  _mycp () {
    if [[ $CURRENT -ge $#words && $words[CURRENT-1] = */* ]]
    then
      compadd $words[CURRENT-1]:t
    fi
    _cp
  }
  compdef _mycp cp

This could be refined in several ways, e.g., you might prefer

  if [[ $CURRENT -ge $#words && $words[CURRENT-1] = */* &&
        $words[CURRENT] != */* ]]


      reply	other threads:[~2006-10-11 16:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-09 19:15 zzapper
2006-10-10  2:38 ` Phil Pennock
2006-10-11  9:13 ` zzapper
2006-10-11 16:38   ` 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=061011093837.ZM18049@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.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).