1

For example, for the command

cp src_file dst_file

my tcsh can complete for src_file if I type src then press TAB, but it does not try to complete for dst_file if I type dst then press TAB.

Output of complete cp (per @shx2's request):

% complete cp
complete cp 'c/--/(archive backup no-dereference force interactive link preserve parents sparse recursive symbolic-link suffix update verbose version-control one-file-system help version)/' 'c/-/(a b d f i l P p R r S s u V v x -)/' 'n/-*r/d/' 'n/{-S,--suffix}/x:<suffix>/' 'n/{-V,--version-control}/(t numbered nil existing never simple)/' 'n/-/f/' 'N/-/d/' 'p/1/f/' 'p/2/d/' 'n/*/f/' 

Is there any setting I missed?

dbc
  • 104,963
  • 20
  • 228
  • 340
Yorkwar
  • 1,204
  • 1
  • 11
  • 27
  • what *does* happen when you press `TAB`? what happens if you try the same thing when typing `\cp` instead of `cp`? – shx2 Mar 21 '14 at 08:52
  • If I press `TAB` immediately after `cp src_file `, the contents in the directory is shown. If after `cp src_file d`, nothing is shown. Using `\cp` has the same result. – Yorkwar Mar 24 '14 at 02:05
  • what's the output of `alias cp` and of `complete cp`? – shx2 Mar 24 '14 at 05:34
  • The output is shown below `yorkwra:[trunk/3rdparty/arm_fastmodel]>alias cp yorkwar:[trunk/3rdparty/arm_fastmodel]>complete cp 'c/--/(archive backup no-dereference force interactive link preserve parents sparse recursive symbolic-link suffix update verbose version-control one-file-system help version)/' 'c/-/(a b d f i l P p R r S s u V v x -)/' 'n/-*r/d/' 'n/{-S,--suffix}/x:/' 'n/{-V,--version-control}/(t numbered nil existing never simple)/' 'n/-/f/' 'N/-/d/' 'p/1/f/' 'p/2/d/' 'n/*/f/'` – Yorkwar Mar 27 '14 at 08:28

2 Answers2

1

Try uncomplete cp to remove the default completion. You can even do uncomplete * if you are super-frustrated :-)

Where the completions come from : tcsh sources /etc/csh.cshrc during the logon, which, in turn, sources /etc/profile.d/complete.tcsh, which, on tcsh 6.18.01 on cygwin 1.7 is a 1228-line file with a lot of custom completions! The completion for cp does not autocomplete the 2nd file and forces you to type it just in case you accidentally overwrite an existing file in haste.

tcsh has had programmable completions since 1993 and has an extensive syntax for defining completions. The upside is that you can do stuff like

complete dbx 'p/2/(core)/'

which defines a positional completion in place 2 for dbx to be the word "core", which is the most common completion for the dbx debugger in position 2, and seeing "core" appear there when you press TAB is pretty cool.

The downside is that there's a whole syntax to learn in case /etc/profile.d/complete.tcsh is not doing what you expect. I have so far managed to avoid learning that syntax since uncomplete works fine for me in such cases. YMMV. :-)

vijucat
  • 2,059
  • 1
  • 15
  • 17
0

You have a custom complete rule for cp, which results with a behavior which you report as unexpected. So it is probably a bad rule.

You can simply disable it:

uncomplete cp

and/or remove the complete cp command from your dot file (probably .cshrc, or another dot file sourced from within it.

shx2
  • 61,779
  • 13
  • 130
  • 153
  • I've re-installed a 64-bit cygwin on Windows 7 now. The `cp` here works fine. Thanks anyway. BTW:I do not have any `complete cp` command in my shell config file. – Yorkwar Apr 14 '14 at 04:12
  • @Yorkwar, from your comment, *something* defines a `complete cp` command *somewhere. It is possible it is "hidden" as `complete {cmd1,cmd2,cp,cmdx} ...` – shx2 Apr 14 '14 at 05:02
  • I'm using the same copy of .cshrc for my new 64-bit Cygwin. Maybe the old Cygwin system does it. – Yorkwar Apr 14 '14 at 06:08