zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@brasslantern.com>
To: Timothy J Luoma <luomat+zsh+users@luomat.peak.org>,
	zsh-users@math.gatech.edu
Subject: Re: completion help?
Date: Sun, 16 Nov 1997 18:48:57 -0800	[thread overview]
Message-ID: <971116184857.ZM21568@candle.brasslantern.com> (raw)
In-Reply-To: <199711170111.UAA01143@luomat.peak.org>

On Nov 16,  8:11pm, Timothy J Luoma wrote:
} Subject: completion help?
}
} I've never really understood completions functions.

You aren't alone.

} compctl -K allapps 'S[-]' -- run

That assigns the completion `-K allapps' to the three commands S[-], --,
and run.  I'm pretty sure that's not what you mean.  Normally you'd only
use things that look like 'S[-]' and '--' when the -x option is present.

} I can get the names of the applications using this:
} 
} sed 's/.*\///g' ~/.AppInfo/LaunchBar/Setup|sed 's/\.app$//g'

That's the same as

    sed 's/.*\/\(.*\)\.app$/\1/' ~/.AppInfo/LaunchBar/Setup

The \1 in the replacement refers to the stuff inside \( \) in the pattern.

You could write a cryptic-looking variable replacement that's equivalent,
using $(<...), but I wouldn't bother.

} How can I make a function that will allow me to do:
} 
} run [tab]
} run S[tab]

If you can do the former, you can do the latter; zsh takes care of that
part itself, so nothing special is necessary.

function allapps()
{
    reply=( $(sed 's/.*\/\(.*\)\.app$/\1/' ~/.AppInfo/LaunchBar/Setup) )
}
compctl -K allapps run
compctl -x 'c[-1,-a]' -K allapps -- open

} Clues for the clueless?

The first compctl should be pretty obvious.

The second one says:
 -x	we're going to use extended completion to
 c[,]	match a string in some other word relative to the "c"urrent one
 -1	and that word is the word immediately preceding the current one
 -a	and if that word matches "-a"
 -K	then run the function
 allapps
 --	now we're done defining the completion, so
 open	is the command to which this completion applies.

Hence `allapps' will generate the completions for `run' and `open -a'.

More clueful?

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


      reply	other threads:[~1997-11-17  3:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-11-17  1:11 Timothy J Luoma
1997-11-17  2:48 ` 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=971116184857.ZM21568@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=luomat+zsh+users@luomat.peak.org \
    --cc=zsh-users@math.gatech.edu \
    /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).