zsh-users
 help / color / mirror / code / Atom feed
From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-users@sunsite.dk
Cc: Will Yardley <william@hq.newdream.net>
Subject: Re: comptctl help
Date: Fri, 27 Jul 2001 15:42:22 +0200 (MET DST)	[thread overview]
Message-ID: <200107271342.PAA24170@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: <20010726165246.D5669@hq.newdream.net>

Will Yardley wrote:

> i was wondering if someone could give me a little help with a couple of my
> compctls.  i'd prefer not to use the menu configuration for these - i like
> having it in a file, and i don't have a recent version of zsh on all of the
> machines i use.

Hm.

> this works great for me, but if i try to cd into a hidden directory (say
> .ssh / .netscape whatever) it won't autocomplete.  presumably i need to add
> .??*(-/) somehow but i haven't been able to figure out how to do 'or' for
> this particular expression.  i tried adding both separately with -g for each,
> and i tried putting them between parenthesis with a pipe in between.  sorry
> for the dumb question.
> 
> here's what i currently have.
> 
> # cd, rmdir etc. only accept dirs as arguments
> compctl -g '*(-/)' cd chdir dirs pushd rmdir

Depending on your preference, use either:

  compctl -g '*(D-/)' cd ...

or

  compctl -g '*(-/)' + -g '.*(-/)' cd ...


> also, i have this for scp:
> 
> # for scp or rcp we look for filenames or hostnames
> 
> filehosts() {
>    local argc argv pref filenames hostnames
>    read -nc argc
>    read -Ac argv
> 
>    pref=$argv[$argc]
>    setopt nullglob

If you set an option in a function, you'll also setopt localoptions on
zsh version that support it.  But in this case you could just use the
glob qualifier `(N)', so...

>    filenames=( ${pref}* )

you could use (and this should also solve the other problem you have
with this function):

  filenames=( ${pref}*(N-^/) ${pref}*/ )

>    hostnames=( ${(M@)hosts:#${pref}*} )
>    if [[ ${#filenames} -eq 0 && ${#hostnames} -eq 1 ]]; then
>        reply=

  reply=()

would be nicer

>    else
>       reply=( $filenames $hostnames )
>    fi
>    return
> }
> 
> compctl -K filehosts + -k hosts -S ':' + -u -S '@' \
>        -x 'n[1,@]' -k hosts -S ':' - 'W[1,*:*]' -f -- rcp scp scp2
> 
> this works, but if i'm trying to copy a file that is in a different
> directory, it completes the directory as if it's a file; ie if i'm trying to
> copy:
> junk/rfc2317.txt
> and i type scp ju<tab>
> it will complete to scp junk[space]
> instead of junk/
> so that i can then tab complete the filename.
> 
> it also doesn't work so well on older versions of zsh - sometimes it will
> complete the username wrong or only give me some of the usernames as options.

This isn't enough information to enable to help you.  No way to get
newer versions running there?


Bye
  Sven


-- 
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


  reply	other threads:[~2001-07-27 13:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-26 23:52 Will Yardley
2001-07-27 13:42 ` Sven Wischnowsky [this message]
2001-07-27 18:37   ` Will Yardley
2001-07-30  7:29     ` Sven Wischnowsky

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=200107271342.PAA24170@beta.informatik.hu-berlin.de \
    --to=wischnow@informatik.hu-berlin.de \
    --cc=william@hq.newdream.net \
    --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).