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

Support zsh, fish, and Powershell autocompletion, fixes #327 #2234

Merged
merged 7 commits into from
May 28, 2020

Conversation

rfay
Copy link
Member

@rfay rfay commented May 4, 2020

The Problem/Issue/Bug:

#327 requests zsh autocomplete.

How this PR Solves The Problem:

  • Generate the autocomplete scripts (bash, fish, zsh, powershell)
  • Include them in artifacts generation (CircleCI)
  • In install script and homebrew and AUR and Windows installer put them where they belong
  • Docs for installation of each autocomplete (including manual bash autocomplete)
  • homebrew: Install _ddev in brew's /usr/local/share/zsh/site-functions

Manual Testing Instructions:

  • With zsh, follow the instructions in the docs to install ddev completions.
  • With zsh, run the install script (install_ddev.sh) and verify that the zsh instructions there work.
  • Test out autocompletion with lots of ddev commands and flags. (They may not all work.)

Automated Testing Overview:

Related Issue Link(s):

Release/Deployment notes:

  • homebrew install output needs to be updated to explain how to install _ddev zsh autocomplete
  • Check AUR path (I think it just uses install_ddev.sh) and see if output is adequate.

@rfay
Copy link
Member Author

rfay commented May 4, 2020

This zipfile contains _ddev, the zsh autocomplete file. To test, please unzip it into your local $fpath, then rm -f ~/.zcompdump && compinit. You should then have zsh autocompletion working.

ddev_zsh_autocompletes.zip

@rfay
Copy link
Member Author

rfay commented May 4, 2020

Autocompletions for fish, zsh, bash, and PowerShell are in this zipfile:

completions.zip

@rfay rfay changed the title Support zsh autocomplete, fixes #327 Support zsh, fish, and Powershell autocompletion, fixes #327 May 4, 2020
@rfay rfay linked an issue May 8, 2020 that may be closed by this pull request
@NBZ4live
Copy link
Contributor

NBZ4live commented May 17, 2020

Maybe it's the best to do it like in Kubernetes?
https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion

In short:

Instead of generating the files in CI and copy them around and dealing with differences in OS and Linux Distro placing, K8S provides a kubectl completion command which accepts the shell type as a parameter.

This way for bash you do:
echo 'source <(kubectl completion bash)' >>~/.bashrc

For Zsh:
echo 'source <(kubectl completion zsh)' >>~/.zshrc

@rfay
Copy link
Member Author

rfay commented May 17, 2020

That's what we actually do for generation; we have a separate executable (in this PR) that generates the completions. It actually uses the same generating code that kubectl does. The problem here is that you can't just add completions to bashrc or .zshrc, that's not where they belong. They're huge, and it would make an enormous mess of .bashrc or .zshrc. And I don't even understand why they suggest changing anything in .bashrc, since it should already be set up on macOS (and usually on Linux) to source the correct directory.

Also, if you read closely in the kubectl instructions, you'll see that they require that you install bash 4, which of course changes the behavior of many things on macOS and would be unacceptable.

Anyway, it's a morass :) But we'll get through it.

@rfay rfay force-pushed the 20200504_zsh_autocomplete branch from 7eef783 to c107bc4 Compare May 28, 2020 03:23
@rfay rfay marked this pull request as ready for review May 28, 2020 03:23
@rfay rfay merged commit e5bfb63 into ddev:master May 28, 2020
@rfay rfay deleted the 20200504_zsh_autocomplete branch May 28, 2020 22:57
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

Successfully merging this pull request may close these issues.

ddev should support zsh autocomplete
2 participants