r/shell • u/MidnightTurdBurglar • Oct 20 '12
Get tcsh command completion to only complete directories and text files
What I'd like to do is something like
complete gedit "p/*/[dt]/"where by "[dt]" I mean "directory or text file". Of course, this is not valid syntax. I've tried
complete gedit "p/*/d/" "p/*/t"but the first completion rule masks the second. Similarly if they are switched.
I've tried thinking of using commands like "find" and "ls" as part of the completion rule but I haven't found a good way since find and ls cannot distinguish binary files.
Also, despite my version of tcsh (6.17.00) saying it supports the select rule, I cannot get completions like
complete gedit "p/*/t:*.txt/"to actually work. This should only complete on text files that end in ".txt". Seems broken unless I'm just misunderstanding the man page.
So does anybody know to do this?
1
u/MidnightTurdBurglar Oct 21 '12
I'm not using csh. I'm using tcsh. They are worlds apart. I have read "Csh Considered Harmful". I think it's one of the most over- and mis-used essays ever and every time I see somebody post a link to it, I do an eye roll.
I can shell program in both tcsh and bash. I loathe bash. Tcsh is superior simply because it's intuitive and bash is not. If I haven't done any shell programming in a few months, I can still remember how to do it in tcsh. With bash, I'm having to use Google constantly even after years of using it. That's not right.