I created the example files in my Debian. Indeed, dot -T png -o myTab
doesn't work. Then (after completing manually) dot -T png -o myGraph.graphviz.png myTab
also doesn't work. There are two separate issues.
The general manual for Graphviz programs specifies:
-ooutfile
Write output to file outfile. […]
Bash completion in my Debian obeys this literally: it supports -ooutfile
, not -o outfile
. Even if the latter works with dot
(and I don't know this), the completion doesn't support it. You should proceed like this:
dot -T png -omyTab
without any space after -o
. In my tests the above works.
To make the second Tab work I inspected /usr/share/bash-completion/completions/dot
. The relevant line near the end is:
_filedir dot
This will offer you directories to descend into and files to specify, but only files with names ending with .dot
or .DOT
. Probably you can manually provide a file not matching this pattern and nothing bad will happen, yet if you rely on the completion mechanism then the file name should end properly.
In fact I don't know dot
at all, I know Bash completions a little. Maybe the requirement doesn't make sense and the completion for dot
would be more helpful if it allowed any file. In such case I copy the original file to /etc/bash_completion.d/
and modify the copy, so the line
_filedir dot
at the end of the function becomes
_filedir
This is a system-wide change. The change will not affect existing shells, so start a new bash
to test it. If you cannot (or don't want to) modify /etc/bash_completion.d/
then see this answer. It provides a way to have your private (user-specific) bash_completion.d/
.
Note this change will allow you to type dot -T png -o myTab
and the completion will work. However in this particular case it has nothing to do with -o
internally, it's the general completion for operands and it would work even after some unexpected or invalid option (e.g. dot -T png -: myTab
).
This is cool, I did not know
dot
wants adot
file. I just edited the line in/usr/share/bash-completion/completions/dot
, since this is my personal cygwin installation, and it works!! – Bowi – 2019-09-23T08:33:24.7901@Bowi OK. In general I expect files in
/usr/share/bash-completion/completions/
to be updated without warning (if you ever update/upgrade), so your edit may be reverted in the future. A copy in/etc/bash_completion.d/
will most likely stay untouched. – Kamil Maciorowski – 2019-09-23T08:39:23.113Very good point. Copied it. =) – Bowi – 2019-09-23T08:45:26.107