With the grep command, I tend to use various combinations of -irln and restrict it to include one or more of the same file types py, js, html, css.
E.g.
grep -ril --include=*{html,css}
I'm defining a suite of aliases for various permutations of grep which I use in the following format:
grep.[options].[extensions]
I generate the alias file with a python script which iterates over combinations of options and generates around 100 aliases in this case. Here are some of them:
alias grep.il.html-css='grep -ril --include=*{html,css}'
alias grep.il.html-css='grep -ril --include=*{html,css}'
alias grep.il.html-js='grep -ril --include=*{html,js}'
alias grep.iln.html-js-css='grep -riln --include=*{html,js,css}'
(they also all exclude the node_modules dir. I hid that for brevity, but now you know why I want these aliases!)
The reason I use full stops is because thanks to completion, it feels almost like typing properties on objects in an IDE, but not quite, and that's what I need help with.
The tab key attempts to select the first complete command it finds. I want it to cycle through the options up until the full stop (in the current namespace if you like).
Currently (untouched Mint/Ubuntu/Debian bash defaults) if I type this:
grep.i
And hit tab, it goes straight to:
grep.i.css
Whereas I would like it not to do that, but to cycle through the options available up until the next full stop first:
grep.i
grep.il
grep.in
grep.iln
grep.l
grep.n
And when I hit . it selects that option, after which tab would then cycle through the options available from off there, such as:
grep.il.css
grep.il.css_html
grep.il.css_js_html
Is this possible? Advisable?
I'm using bash, would consider moving to zshell if that's the only way.
UPDATE:
I can improve this situation with a little hack, which is to create a stub alias for every intermediate alias, so in the above example:
alias grep.='echo stub'
alias grep.il.='echo stub'
This stops on the full stop, but completion adds a space after so I end up with:
"grep. "
at the terminal. I can still tab to cycle through the options, but need to backspace before I start typing else I get:
"grep. i"
I've looked at the option of creating custom autocompletion behaviour making it not add a space after commands which have a . in them, but that catches files too (e.g. it would mess up main.py hello
) I'll keep digging...
complete -o nospace -F _longopt grep
complete -o nospace less
andcompopt +o nospace less
onless
and other commands and it still always adds a space.