COMPREPLY by default returns a space separated list of words, but I'd like to have it return a single word per line. I've tried putting newlines at the ends of the words and have looked through the docs for both compgen and complete but can't find anything.
Is this possible?
EDIT:
Sorry I really explained that poorly. I have a script that is bound to an autocomplete function via complete -F. When the user runs the script, hitting tab twice will show a list of possible options via compgen. Right now the function has lines of code like this:
COMPREPLY=( $(compgen -W '$( ls ~/work/dev/jobs/ | cat )' -- $curword ) )
When the user hits tab though, these directories are displayed like:
directory0 directory1 directory2 directory3
but i would like them displayed like:
directory0
directory1
directory2
directory3
I posted a similar thread to /r/bash and someone suggested doing
bind 'set completion-display-width 0'
which works, and then I can unset it with
bind 'set completion-display-width -1'
The issue now is that if I unset it before the complete function returns, it has no effect, so I unset it in the script after the user has pressed enter. This works fine, but if the user starts using the autocomplete, and then changes their mind and delets what they had entered and were to return to the shell, completion-display-width would still be set to 0.
Is there another way to go about this?
printf "%s\n" space separated list
,tr ' ' '\n'
,sed 's/\s/\n/g'
, etc.