I have written a shell script for autocompletion(bash); which, on sourcing, runs a python script, stores the output of the script and acts as a source of word list for the compgen command. Following is the partial script:

output="$(python my_script.py)"

function _autocomp()
    COMPREPLY=($(compgen -W "${output}" -- ${current_word}))

complete -F _autocomp nutest

The output of the python script is a list of strings and the length of the list is around 21000. This makes autocompletion very sluggish and slow. Is there a way to optimise this to make it faster?

  • The usability of a list of 21000 elements is low, can't you return an empty list until the user has entered enough characters to reduce the list to something manageable? – xenoid Jul 4 '18 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.