zsh-users
 help / color / mirror / code / Atom feed
* completing nothing
@ 2012-10-25 18:13 Micah Elliott
  2012-10-25 23:00 ` Oliver Kiddle
  0 siblings, 1 reply; 2+ messages in thread
From: Micah Elliott @ 2012-10-25 18:13 UTC (permalink / raw)
  To: Zsh Users

I'm wondering if it's possible to do a tab-completion at the very
start of the command line, with a custom completion (of the empty
command). I see that there's already some special (non-)behavior in
that no completion is attempted, but an actual tab is inserted; the
goal is to override that. I'm working on a kid-friendly setup and
would like them to be able to just say «tab» to see a short list of
simple commands (actually short aliases). So the example would be:

prompt% «tab»
b -- start up a Browser
c -- conCatenate a file to the screen (cat)
d -- show the Directories you've visited (dirs)
e -- Explore in a file browser
f -- Fix your recent history of commands (fc)
j -- see your running Jobs
l -- List files and directories
m -- read the Manual for a command
p -- Print something to the screen
...

A workaround would be to just teach them to use an "h" command that
would accomplish the same thing. Or I could create a set of
comma-started short commands/aliases, so they could just hit ,«tab»
(similar vein to psql/sqlite help) to see them. But I'd prefer to get
them used to hitting «tab» whenever in doubt. This might not be worth
it, but thought I'd ask if it's presently possible. I have a little
experience writing some simple completions with compsys, but just
don't know what to key into with compdef for this empty command.

I'd also like to make sure this doesn't change any default behavior. I
don't see any need to insert an actual tab as is done now, but it
seems if you type $«tab» it should still complete params, and other
such special character at the prompt start would still need to behave
normally.

Regards,
Micah
--
Micah Elliott
Remember your words with Membean. Three free days of learning!


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: completing nothing
  2012-10-25 18:13 completing nothing Micah Elliott
@ 2012-10-25 23:00 ` Oliver Kiddle
  0 siblings, 0 replies; 2+ messages in thread
From: Oliver Kiddle @ 2012-10-25 23:00 UTC (permalink / raw)
  To: Micah Elliott; +Cc: Zsh Users

Micah Elliott wrote:
> I'm wondering if it's possible to do a tab-completion at the very
> start of the command line, with a custom completion (of the empty
> command). I see that there's already some special (non-)behavior in
> that no completion is attempted, but an actual tab is inserted; the

Yes, try:
  zstyle -e ':completion:*:*:-command-:*' tag-order '
      [[ -n $PREFIX$SUFFIX || $1 = messages ]] || 
            { reply=( - ); compadd a b c }'

If that works, write your own completion function to replace the compadd
command in there to complete your list of aliases.

Oliver


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-25 23:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-25 18:13 completing nothing Micah Elliott
2012-10-25 23:00 ` Oliver Kiddle

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).