1

I have to launch my applications using a number of prefix commands (like xvbf-run). The launch scripts/applications have a functioning autocomplete. So the following works script1 <TAB><TAB>.

But the following fails to work correctly {prefix with options} script1 <TAB><TAB> (obviously). Since the options are fixed, I created a simple function:

function prefix_summary () {
    {prefix with options} $@ 
}

I tried complete -F _longopt prefix_summary but that doesn't work. How can I allow prefix_summary to act like a bash prompt?

TLDR: make this $ prefix_summary <TAB><TAB> give same autocomplete options as this $ <TAB><TAB>

0

1 Answer 1

1

If I understand your question, you want a sudo-like completion.

Let's look at how completion is defined for sudo:

$ complete -p sudo
complete -F _sudo sudo

Then, you only need to apply the same completion rules (defined in the function _sudo()) to your prefixes.

$ complete -F _sudo prefix1 prefix2

Now, hitting Tab ↹ after $ prefix1 and $ prefix2 will autocomplete with commands from paths in $PATH.

Hitting Tab ↹ after $ prefix1 cmd1 will autocomplete with suggestions from cmd1 completion rules.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .