Perhaps the execution of an arbitrary command?

I'm looking for a way to connect to a custom bash completion function. The problem is that I want this completion function not only for a specific command, but for all teams.

Is it possible? Looking around for a while, I could not find any resources on the Internet.

To reduce the problem to the most trivial case: is it possible to always have tab completion for the string "foo"?

The value of echo f<tab> will expand to echo foo , and ls fo<tab> will expand to ls foo

In context: I'm trying to implement something similar to http://blog.plenz.com/2012-01/zsh-complete-words-from-tmux-pane.html in bash, but I'm starting to fear that this is not possible.

+5
source share
1 answer

You can do this with the -D option of the complete command:

 suggest_hello() { COMPREPLY=( hello ) return 0 } complete -D -F suggest_hello 

Now when I type echo h<Tab> , I get echo hello .

 $ help complete complete: ... ... -D apply the completions and actions as the default for commands without any specific completion defined ... 
+4
source

All Articles