dbt-labs / dbt-completion.bash

Adds autocompletion to the dbt CLI
https://www.getdbt.com/
Apache License 2.0
116 stars 29 forks source link

Complete prefix in zsh #22

Closed Thrasi closed 7 months ago

Thrasi commented 7 months ago

I have a bunch of models with prefixes stg_ or int_ I would like to be able to tab complete the prefix from just the name after the prefix. i.e. If I have 3 models: stg_model_a_v1, stg_model_a_v2 and stg_model_a_v3 I would like this to happen:

$ dbt run -s model_a<TAB>

to become:

$ dbt run -s stg_model_a_v
stg_model_a_v1   stg_model_a_v2   stg_model_a_v3

I know this is possible since this is the default functionality for autocompletion for e.g. ls

I am very new to zsh so contributing myself seems like a long shot.

b-per commented 7 months ago

I am pretty sure that this is how it works today already with the zsh completion.

I just did a dbt run -s g_snowp<TAB> and it became dbt run -s stg_snowplow_

Thrasi commented 7 months ago

You are absolutely right. However, I do notice some strange behaviour, that could just be a misconfiguration on my system. I was testing with a model called cluster_transactions, and then I have models called transactionsDaily, transactionsMonthly When I write transactions<TAB> I get:

$ transactions
 transactionsDaily     transactionsMonthly

but without the first t $ ransactions<TAB> becomes

$ transactions
int_transactions. stg_transactions   transactionsDaily     transactionsMonthly

It looks like that when there exist models without a prefix and I tab from the very beginning only the models without the prefix are displayed but if all the models have a prefix, then it will suggest them.