zsh-users
 help / color / mirror / code / Atom feed
* compctl help needed for IRC channel names
@ 2017-11-07 21:13 Aleksandr Miroslav
  2017-11-08  0:08 ` Aleksandr Miroslav
  2017-11-10 22:42 ` Bart Schaefer
  0 siblings, 2 replies; 4+ messages in thread
From: Aleksandr Miroslav @ 2017-11-07 21:13 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 464 bytes --]

My IRC bouncer (ZNC), writes out IRC logs into directories that look like
this:

/path/network1/#channel1
/path/network1/##channel2
/path/network1/user1
/path/network2/#channel3
/path/network2/##channel4
/path/network2/user2

I would like compctl to autocomplete for me with these options:

channel1 channel2 user1 channel3 channel4 user2

But, when I choose channel1 or whatever, it should return the full real
path (/path/network1/#channel1)

How can I do this?

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

* Re: compctl help needed for IRC channel names
  2017-11-07 21:13 compctl help needed for IRC channel names Aleksandr Miroslav
@ 2017-11-08  0:08 ` Aleksandr Miroslav
  2017-11-10 22:42 ` Bart Schaefer
  1 sibling, 0 replies; 4+ messages in thread
From: Aleksandr Miroslav @ 2017-11-08  0:08 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 883 bytes --]

I solved this by writing a small script that listed the main directories
and converted them to an abbreviated form.

I feed the abbreviated list to compctl -k, and then I also added a
"converter" which takes the abbreviated form and converts it back to the
full path, which I use in my command.



On Tue, Nov 7, 2017 at 1:13 PM, Aleksandr Miroslav <alexmiroslav@gmail.com>
wrote:

> My IRC bouncer (ZNC), writes out IRC logs into directories that look like
> this:
>
> /path/network1/#channel1
> /path/network1/##channel2
> /path/network1/user1
> /path/network2/#channel3
> /path/network2/##channel4
> /path/network2/user2
>
> I would like compctl to autocomplete for me with these options:
>
> channel1 channel2 user1 channel3 channel4 user2
>
> But, when I choose channel1 or whatever, it should return the full real
> path (/path/network1/#channel1)
>
> How can I do this?
>
>
>

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

* Re: compctl help needed for IRC channel names
  2017-11-07 21:13 compctl help needed for IRC channel names Aleksandr Miroslav
  2017-11-08  0:08 ` Aleksandr Miroslav
@ 2017-11-10 22:42 ` Bart Schaefer
  2017-11-10 23:15   ` Bart Schaefer
  1 sibling, 1 reply; 4+ messages in thread
From: Bart Schaefer @ 2017-11-10 22:42 UTC (permalink / raw)
  To: Aleksandr Miroslav, zsh-users

On Nov 7,  1:13pm, Aleksandr Miroslav wrote:
} 
} My IRC bouncer (ZNC), writes out IRC logs into directories that look like
} this:
} 
} /path/network1/#channel1
} /path/network1/##channel2
} /path/network1/user1
} /path/network2/#channel3
} /path/network2/##channel4
} /path/network2/user2
} 
} I would like compctl to autocomplete for me

It'd be more typical nowadays to run 'compinit' from your startup files
and use the "new" (now 15+ years old) completion system.

} with these options:
} 
} channel1 channel2 user1 channel3 channel4 user2

Meaning these are what show up in a completion listing, e.g., on ^D or
when TAB produces an ambiguous result; but when one is substituted into
the command line, the full path should appear?

} But, when I choose channel1 or whatever, it should return the full real
} path (/path/network1/#channel1)
} 
} How can I do this?


-- 
Barton E. Schaefer


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

* Re: compctl help needed for IRC channel names
  2017-11-10 22:42 ` Bart Schaefer
@ 2017-11-10 23:15   ` Bart Schaefer
  0 siblings, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2017-11-10 23:15 UTC (permalink / raw)
  To: zsh-users

[Oops, that got sent accidentally before I was finished.]

} } But, when I choose channel1 or whatever, it should return the full real
} } path (/path/network1/#channel1)
} } 
} } How can I do this?

With compinit, you'd do something similar to the compctl solution that
you worked out, but it might be a bit simpler.

One thing you haven't told us is whether you want this to apply every
time you complete one of these file paths, no matter what the command
name might be, or whether this is specific to a particular command.
The approach might be somewhat different, depending.

With compinit, you define a list of functions via the "completer" style.
To generically perform your desired operation on file paths, you would
write a completer fuction and include it in the completer style at a
point you feel appropriate.  For a particular command, you'd write a
function that generates the list of matches and associate it with the
command name by using "compdef".

If you're interested in following up on this approach, some more detail
about the context would be helpful.


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

end of thread, other threads:[~2017-11-10 23:22 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-07 21:13 compctl help needed for IRC channel names Aleksandr Miroslav
2017-11-08  0:08 ` Aleksandr Miroslav
2017-11-10 22:42 ` Bart Schaefer
2017-11-10 23:15   ` Bart Schaefer

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