Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autocompletion for Pet #289

Open
4 tasks
RamiAwar opened this issue Feb 28, 2024 · 1 comment
Open
4 tasks

Add autocompletion for Pet #289

RamiAwar opened this issue Feb 28, 2024 · 1 comment

Comments

@RamiAwar
Copy link
Collaborator

RamiAwar commented Feb 28, 2024

  • 289.1 ZSH autocompletion plugin
  • 289.2 Contribute completions to zsh-completions library
  • 289.3 Bash autocompletions
  • 289.4 Fish autocompletions

This is not greatly useful for pet users yet, but in doing this I'll gather up some more knowledge about autocompletion and will then be able to judge whether or not it's possible to build autocompletions that rely on dynamic output from pet.

Couldn't tell from basic research, and this is a nice to have anyways.

@RamiAwar
Copy link
Collaborator Author

Still need to look into this, but I have something working.

ZSH autocompletion template:


# Define completion function for the 'pet' command
_pet_complete() {
    local -a pet_commands=("new" "edit" "search" "exec")

    _arguments -C \
        '1: :->command' \
        '*::arg:->args'

    case $state in
        (command)
            # Complete the command based on the list of commands
            _describe 'command' pet_commands
            ;;
        (args)
            # Do nothing for now, you can add additional completions for command arguments here
            ;;
    esac
}

# Register completion function
_zstyle ':completion:*:pet:*' completer _pet_complete

# Call the completion function
_pet_complete "$@"```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant