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

feat: initial plugin implementation for client binaries #1

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_tsh
_tctl
_tbot
21 changes: 21 additions & 0 deletions init.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
generate_completions() {
if [[ ${+commands[(e)${2}]} || ${+commands[asdf]} && ${+functions[_direnv_hook]} ]]; then

local command=${commands[(e)${2}]:-"$(${commands[asdf]} which $2 2> /dev/null)"}

[[ -z $command ]] && return 1

local compfile=$1/functions/_$2
if [[ ! -e $compfile || $compfile -ot $command ]]; then
$command --completion-script-zsh >| $compfile
print -u2 -PR "* Detected a new version '$2'. Regenerated completions."
fi
fi
}

# Teleport user CLI
generate_completions "${0:h}" tsh
# Teleport admin CLI
generate_completions "${0:h}" tctl
# Machine ID Bot
generate_completions "${0:h}" tbot