Custom auto-complete

Hello:

I am using csh, and am a complete noob when it comes to shell scripting.

I want the following:

1) Ignore case when doing auto-complete.

2) If there are multiple matches (example: I have files abc.txt abc.txt.1, abc.txt.2 and type abc<tab>), count the number of matches.

If the number of matches is less than a set amount, say 5, then cycle through them upon tab. Meaning when I press abc<tab> it first completes abc.txt, then when I press <tab> again, it completes it to abc.txt.1, then abc.txt.2, and then my original uncompleted word, abc.

If the number of matches is more than 5 and less than 20, it should show me all possibilities upon pressing tab.

If the number of matches is more than 20, it should ask me whether I want a full listing. Upon pressing y or n, it should do the appropriate action (i.e. show me all possible matches, or not show any match).

3) When the number of matches is less than 5, shift-tab should cycle backwards in the list of matched filenames/dir-names.

I want to write a script in .cshrc to do the above, but don't know how/where to start. Can anyone help me write this?

Regards,

[Bump]

Bumping this topic, since I did not get any answer.