zsh-users
 help / color / mirror / code / Atom feed
* generic filename completion like "foo --file=ba<tab>"
@ 2001-12-11 12:21 Michael Wardle
  2001-12-11 12:28 ` Peter Stephenson
  0 siblings, 1 reply; 8+ messages in thread
From: Michael Wardle @ 2001-12-11 12:21 UTC (permalink / raw)
  To: zsh-users

Hi.

I'm a former bash user starting to learn zsh.  I'm currently running
zsh 4.0.2 on Red Hat Linux, and zsh seems to be missing a feature I
like.

In bash, I could do:
dd if=root.img of=/dev/f<tab>

In zsh, pressing the filename completion key (tabulate) does not
produce the desired result.  It seems to work fine where the filename
is separated by whitespace, but not where the filename is embedded in a
text string.

Many commands (particularly GNU utilities) take arguments in the form
--option=value, and value can often be a filename.  If I could easily
make zsh do this completion, my life would be easier!  :-)

I searched the archives of this mailing list, and could not find any
answer to this question, but over 5000 hits turned up, so I might have
missed something.  (The closest one is this:
<URL:http://www.zsh.org/mla/users//1997/msg00456.html>
but it does not seem to have a satisfactory answer.)

Any help (even a pointer to a relevant FAQ) would be most appreciated.

Cheers.




=====
MICHAEL WARDLE

MAIL   michael@endbracket.net
MOBILE 0415 439 838
WWW    http://www.endbracket.net/michael/


__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com


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

* Re: generic filename completion like "foo --file=ba<tab>"
  2001-12-11 12:21 generic filename completion like "foo --file=ba<tab>" Michael Wardle
@ 2001-12-11 12:28 ` Peter Stephenson
  2001-12-11 12:32   ` Will Yardley
                     ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Peter Stephenson @ 2001-12-11 12:28 UTC (permalink / raw)
  To: Zsh users list, Michael Wardle

Michael Wardle wrote:
> Hi.
> 
> I'm a former bash user starting to learn zsh.  I'm currently running
> zsh 4.0.2 on Red Hat Linux, and zsh seems to be missing a feature I
> like.
> 
> In bash, I could do:
> dd if=root.img of=/dev/f<tab>
> 
> In zsh, pressing the filename completion key (tabulate) does not
> produce the desired result.

The new completion system will do this, and has completion of dd arguments
as well.  There's no mileage in trying to add this to the old system now.
It's automatic if you run compinit.
  autoload -U compinit
  compinit
See the zshcompsys manual page.

You might want to `setopt magicequalsubst' for the best effect.  This will
force zsh to recognise ~-expansion after all equal signs.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: generic filename completion like "foo --file=ba<tab>"
  2001-12-11 12:28 ` Peter Stephenson
@ 2001-12-11 12:32   ` Will Yardley
  2001-12-11 12:44     ` Peter Stephenson
  2001-12-11 12:49   ` Borsenkow Andrej
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Will Yardley @ 2001-12-11 12:32 UTC (permalink / raw)
  To: Zsh users list

Peter Stephenson wrote:
> 
> The new completion system will do this, and has completion of dd
> arguments as well.  There's no mileage in trying to add this to the
> old system now.  It's automatic if you run compinit.

if anyone knows how to do this without using the new completion system
i'd like to know about it.

i still don't really understand... is there a way to use parts of the
new completion system without loading the whole shebang? believe it or
not, there are certain things that i _don't_ want to complete (or that i
like doing my own way)... is there a way to load only specific functions
from the new system?

-- 
The three wise men brought frank incest and mirth.


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

* Re: generic filename completion like "foo --file=ba<tab>"
  2001-12-11 12:32   ` Will Yardley
@ 2001-12-11 12:44     ` Peter Stephenson
  0 siblings, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2001-12-11 12:44 UTC (permalink / raw)
  To: Zsh users list

Will Yardley wrote:
> i still don't really understand... is there a way to use parts of the
> new completion system without loading the whole shebang? believe it or
> not, there are certain things that i _don't_ want to complete (or that i
> like doing my own way)... is there a way to load only specific functions
> from the new system?

You could exclude the functions you don't want from your path.  This
obviously needs some reorganising of $fpath or the directories, but for
example, if you have the functions installed in hierarchical directories,
you could remove
/usr/local/share/zsh/4.0.2/functions/Completion/Unix/Command
from $fpath, link any commands you do want completion for into a
different directory, and add that to your path.

You could also post-process the associative array $_comps after loading the
completion system.  This gives the functions to be used for a given
context, typically a command name, e.g. ${_comps[dd]} is _dd.  You can
unset elements you don't want completion for.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* RE: generic filename completion like "foo --file=ba<tab>"
  2001-12-11 12:28 ` Peter Stephenson
  2001-12-11 12:32   ` Will Yardley
@ 2001-12-11 12:49   ` Borsenkow Andrej
  2001-12-11 13:25     ` Vincent Lefevre
  2001-12-11 12:55   ` Peter Stephenson
  2001-12-11 15:09   ` Oliver Kiddle
  3 siblings, 1 reply; 8+ messages in thread
From: Borsenkow Andrej @ 2001-12-11 12:49 UTC (permalink / raw)
  To: 'Peter Stephenson', 'Zsh users list',
	'Michael Wardle'

> > I'm a former bash user starting to learn zsh.  I'm currently running
> > zsh 4.0.2 on Red Hat Linux, and zsh seems to be missing a feature I
> > like.
> >
> > In bash, I could do:
> > dd if=root.img of=/dev/f<tab>
> >
> > In zsh, pressing the filename completion key (tabulate) does not
> > produce the desired result.
> 
> The new completion system will do this, and has completion of dd
arguments
> as well.

Yes and now. It does have completion for dd but it does not do it for
arbitrary command. I am not sure if it is a bug or feature. After all,
you cannot assume that `=' is always followed by file name.

You can configure default completion to be smarter. In new completion it
would use something like

[[ compset -P *= ]] && return _files
return 1

and then you need to tell to use it as fallback but do not ask me at the
moment how to do it :-) I expected it to be

put the above is some function like _default_completion
use compdef to define it:

compdef _default_completion -default-

but it does not work

-andrej


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

* Re: generic filename completion like "foo --file=ba<tab>"
  2001-12-11 12:28 ` Peter Stephenson
  2001-12-11 12:32   ` Will Yardley
  2001-12-11 12:49   ` Borsenkow Andrej
@ 2001-12-11 12:55   ` Peter Stephenson
  2001-12-11 15:09   ` Oliver Kiddle
  3 siblings, 0 replies; 8+ messages in thread
From: Peter Stephenson @ 2001-12-11 12:55 UTC (permalink / raw)
  To: Zsh users list

Peter Stephenson wrote:
> Michael Wardle wrote:
> > In bash, I could do:
> > dd if=root.img of=/dev/f<tab>
> > 
> > In zsh, pressing the filename completion key (tabulate) does not
> > produce the desired result.
> 
> The new completion system will do this, and has completion of dd arguments
> as well.  There's no mileage in trying to add this to the old system now.

I was a bit pessimistic here.  The file Misc/compctl-examples in the
distribution has the following.  The 's[if=]' is of general applicability
for the old extended complete (after -x).

#------------------------------------------------------------------------------
# dd
compctl -k '(if of conv ibs obs bs cbs files skip file seek count)' \
	-S '=' -x 's[if=], s[of=]' -f - 'C[0,conv=*,*] n[-1,,], s[conv=]' \
	-k '(ascii ebcdic ibm block unblock lcase ucase swap noerror sync)' \
	-q -S ',' - 'n[-1,=]' -X '<number>'  -- dd

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


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

* Re: generic filename completion like "foo --file=ba<tab>"
  2001-12-11 12:49   ` Borsenkow Andrej
@ 2001-12-11 13:25     ` Vincent Lefevre
  0 siblings, 0 replies; 8+ messages in thread
From: Vincent Lefevre @ 2001-12-11 13:25 UTC (permalink / raw)
  To: 'Zsh users list'

On Tue, Dec 11, 2001 at 15:49:16 +0300, Borsenkow Andrej wrote:
> Yes and now. It does have completion for dd but it does not do it for
> arbitrary command. I am not sure if it is a bug or feature. After all,
> you cannot assume that `=' is always followed by file name.

After all, you cannot assume that an argument is always a filename.
However, the default behaviour is to complete to a filename. I think
we should have the same behaviour (possibly optional) after a "=".

-- 
Vincent Lefèvre <vincent@vinc17.org> - Web: <http://www.vinc17.org/> - 100%
validated HTML - Acorn Risc PC, Yellow Pig 17, Championnat International des
Jeux Mathématiques et Logiques, TETRHEX, etc.
Work: CR INRIA - computer arithmetic / SPACES project at LORIA


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

* Re: generic filename completion like "foo --file=ba<tab>"
  2001-12-11 12:28 ` Peter Stephenson
                     ` (2 preceding siblings ...)
  2001-12-11 12:55   ` Peter Stephenson
@ 2001-12-11 15:09   ` Oliver Kiddle
  3 siblings, 0 replies; 8+ messages in thread
From: Oliver Kiddle @ 2001-12-11 15:09 UTC (permalink / raw)
  To: Zsh users list, Michael Wardle

Peter Stephenson wrote:

> You might want to `setopt magicequalsubst' for the best effect.  This
> will
> force zsh to recognise ~-expansion after all equal signs.

If you look at _default, you'll see that it is set to complete files
after any `=' as part of the default completion if magicequalsubst is
set.

Vincent Lefèvre wrote:

> After all, you cannot assume that an argument is always a filename.
> However, the default behaviour is to complete to a filename. I think
> we should have the same behaviour (possibly optional) after a "=".

This is a fairly valid point. Maybe we should rethink what the default
is here. Perhaps making the default be to complete files here and have
it turned off with a style.

Oliver


__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com


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

end of thread, other threads:[~2001-12-11 15:10 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-11 12:21 generic filename completion like "foo --file=ba<tab>" Michael Wardle
2001-12-11 12:28 ` Peter Stephenson
2001-12-11 12:32   ` Will Yardley
2001-12-11 12:44     ` Peter Stephenson
2001-12-11 12:49   ` Borsenkow Andrej
2001-12-11 13:25     ` Vincent Lefevre
2001-12-11 12:55   ` Peter Stephenson
2001-12-11 15:09   ` 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).