mephs / talosctl-zsh-plugin

An omz plugin for talosctl command completion.
Mozilla Public License 2.0
1 stars 0 forks source link

Should the talosctl completions be recreated every plugin load? #2

Open unixorn opened 5 months ago

unixorn commented 5 months ago

You have the

talosctl completion zsh >| "$ZSH_CACHE_DIR/completions/_talosctl" &|

outside the

if [[ ! -f "$ZSH_CACHE_DIR/completions/_talosctl" ]]; then

stanza. Do you want to recreate the file every time the plugin loads?

mephs commented 5 months ago

@unixorn I took reference from the kubectl plugin. https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/kubectl/kubectl.plugin.zsh

Is that really so bad?

unixorn commented 5 months ago

No, I was just curious. I get wanting to ensure you're running the version of the completion that matches the version of talosctl.

You could optimize it to either do it once per day by checking the creation time of the completion's creation time, or even better, compare it to the completion time of talosctl and only regenerate it when talosctl gets updated.

I noticed it when I was adding the completion to the awesome-zsh-plugins list in https://github.com/unixorn/awesome-zsh-plugins/pull/1840

The only real complication I can think of with your approach (which is the most common one) would be if one shell session was loading the completion file while another was regenerating it and the odds of that are super low.