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

Initial commit for zsh native completion support #7

Merged
merged 3 commits into from
Sep 29, 2020

Conversation

b-per
Copy link
Contributor

@b-per b-per commented Aug 29, 2020

Add support for native zsh completion for the dbt command

As mentioned in issue #6:

Pros:

  • Completion for models works with strings in the middle of the model names (e.g. typing invoice will match models customer_invoice and vendor_invoice
  • Completion has been set up for some flags and commands (listing most of the flags available when running dbt run, dbt test and dbt docs as well as the global flags)
  • Support for '+' and '@' has been replicated from the bash completion script
  • [NEW] This script supports separating models with a comma, as defined in dbt 0.18

Cons:

  • Currently, when running dbt run or dbt test the models will be suggested even though there is no model selection flag defined or if the model selection flag is not the last one in the list

@ghost
Copy link

ghost commented Sep 9, 2020

@camfrout could you include proposed README updates (if any) for installation process if taking this route? i'd love to test this out but i'm not super familiar with completion functionality in zsh and don't want to accidentally bork up my dotfiles making guesses 😅

@b-per
Copy link
Contributor Author

b-per commented Sep 9, 2020

Sure, I have just added instructions. The easy way is if you are already using oh-my-zsh.

README.md Outdated Show resolved Hide resolved
Co-authored-by: grant <hej@grantwinship.com>
@ghost
Copy link

ghost commented Sep 11, 2020

Sure, I have just added instructions. The easy way is if you are already using oh-my-zsh.

Awesome, thank you! I've got it up and running, so far working very nicely! I'll put it through its paces on client work tomorrow - thanks again this is very cool 🌻

@ghost
Copy link

ghost commented Sep 23, 2020

i've had zero issues with this @jtcohen6 -- functions flawlessly, install was a breeze: 👍🏻 👍🏻 from me to merge

@jtcohen6
Copy link
Contributor

Thanks for testing @grantwinship!

@camfrout Tiny thing: could you rename the file from _dbt to something like dbt-completion.zsh, to mirror the existing bash version?

@b-per
Copy link
Contributor Author

b-per commented Sep 26, 2020

Hi.

I don't think I can, it is actually part of the naming convention for ZSH completion scripts.

Source: "Completion functions for commands are stored in files with names beginning with an underscore _, and these files should be placed in a directory listed in the $fpath variable. You can add a directory to $fpath by adding a line like this to your ~/.zshrc file:"

Looking at this repo of ZSH completion scripts, we can see that all the scripts are named _<command>

@jtcohen6
Copy link
Contributor

TIL! Thanks for the links @camfrout. I'm good with merging this as-is, then :)

@jtcohen6 jtcohen6 merged commit c36c45d into dbt-labs:master Sep 29, 2020
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.

None yet

2 participants