0

I have a CLI application that uses Oclif and NodeJS. I have an autocomplete script that looks like this:

# func gets called for the exec binart when Tab is pressed
# eg exec [Tab] [Tab] calls __func()

__func()
{
    Perform an http request that takes 2-3 seconds
    Populate COMPREPLY with autocomplete values
}

complete -o nospace -F __func exec

Since pressing Tab takes a few seconds, it would be nice to have a spinner like functionality in the shell, so that the user can see that the autocomplete is running.

How can I achieve this? Instead of a spinner a progress bar would be nice, or some dots that would indicate loading (...).

1 Answer 1

1

Have you tried to call a spinner before and after your command?

Example spinner:

Example with your code:

    __func()
    {
        spinner.start()
        Perform an http request that takes 2-3 seconds
        Populate COMPREPLY with autocomplete values
        spinner.end()
    }

    complete -o nospace -F __func exec
Sign up to request clarification or add additional context in comments.

1 Comment

__func is written in bash, while spinner.start() / end() are only available in nodejs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.