How can I `source` a file on my path and have it tab-complete? How can I `source` a file on my path and have it tab-complete? shell shell

How can I `source` a file on my path and have it tab-complete?


You can put this into your bashrc:

complete -c source

-c stands for command names which will effectively search in PATH. But that requires that the files are executable. You could elaborate on that and program a custom completion function which uses find to retrieve all shell scripts in PATH.


You can use bash built-in commands "complete, compgen, compopt" to do a customized completion for "source".

Link --> https://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html