• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

tcsh 'complete' question

CTho9305

Elite Member
I have a program that is invoked:
programName string1 -arg1 filex.type1 -arg2 filey.type2
string1 doesn't have to come first: "programName -arg1 filex.type1 string1 -arg2 filey.type2" and "programName -arg1 filex.type1 -arg2 filey.type2 string1" are both legal. How can I set up a tcsh completion to tab complete "arg1", "arg2", and the files? Requiring string1 to come first is acceptable. Requiring string1 to come last is not acceptable. "Use bash|korn|zsh" is not 🙂

A little more detail:
programName string1 -textfile [complete *.txt] -otherfile [complete *.bin]

edit: I have a second program that works similarly but requires string1 to come last. I think I can handle that one by just ignoring string1 for the "complete" command.
 
What parts of the command are always the same? If most of the command stays the same you could write a wrapper script.

Other than that, I'm looking at the doc for the complete built-in now. 😛
 
What do you mean "always the same"?

In normal format, I might document it as:
Usage:
$0 <nameToUse> [-textfile <foo.txt>] [-otherfile <bar.bin>]
The three arguments may be passed in any order, but 95% of people choose this order and if tab-completion only supports one ordering, it has to be this one
 
You said the string was (basically):
programName -arg1 filex.type1 string1 -arg2 filey.type2

Are filex.type1, string1, and filey.type2 relatively constant? I'm guessing they're different a lot of the times (string1 one day, string 7 the next, string2 the next, etc.). It makes a wrapper script a little more difficult, but do-able.

Still looking at the complete documentation. Silly things keep popping up.
 
string1 is different every time. arg1 is usually specified, and requires a file of type1. arg2 is sometimes specified, and requires a file of type2. A wrapper script introduces problems - there are a large number of existing users who are resistant to change 🙂
 
Minimal testing and doesn't work with the .bin file yet:
complete ./programName 'p/2/(-textfile)/' 'p/3/t:*.txt/' 'C/*.txt/t/' 'p/4/(-otherfile)/' 'p/5/f:*.bin/'

EDIT: This one's a bit prettier:
complete ./xfile 'p/2/(-arg1)/' 'n/-arg1/t:*.txt/' 'C/*.txt/t/' 'p/4/(-arg2)/' 'n/-arg2/f:*.bin/'

Still not sure why the .bin option doesn't just pull out the .bin files...
 
Apparently Plain (``text'') files means something different than I thought...

complete ./xfile 'p/2/(-arg1)/' 'n/-arg1/t:*.txt/' 'C/*.txt/t/' 'p/4/(-arg2)/' 'n/-arg2/t:*.bin/'

EDIT: What a silly shell. 😉
 
It hadn't occurred to me to just require p/2 and p/4 for the arguments. I can probably tweak this to meet the rest of my needs. Thanks!
 
Back
Top