dbt-labs/dbt-completion.bash

Complete prefix in zsh

Closed this issue · 2 comments

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.

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_

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.