You did not read documentation carefully:
Call the given function to get the completions. Unless the name starts with an underscore, the function is passed two arguments: the prefix and the suffix of the word on which completion is to be attempted, in other words those characters before the cursor position, and those from the cursor position onwards. The whole command line can be accessed with the -c and -l flags of the read builtin. The function should set the variable
reply
to an array containing the completions (one completion per element); note that reply should not be made local to the function. From such a function the command line can be accessed with the -c and -l flags to the read builtin. For example,
. You must not output anything to stdout from completion function. You must instead set the array variable reply
:
reply=( $(tmux list-sessions | cut -d: -f1) )
. Note that there is no reason for you to invoke perl here, cut
is more suitable. I do not see any lines not matching ^([^:]+)
in the tmux output.