From 368728a512478925e9a0440d35d47fb64d9b4ca7 Mon Sep 17 00:00:00 2001 From: aayu22809 Date: Mon, 4 May 2026 02:02:26 -0700 Subject: [PATCH] Add AWS CDK plugin Add an Oh My Zsh plugin for AWS CDK that registers yargs-based zsh completions and falls back to an npx wrapper for project-local CDK installations. --- plugins/cdk/README.md | 15 +++++++++++++++ plugins/cdk/cdk.plugin.zsh | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 plugins/cdk/README.md create mode 100644 plugins/cdk/cdk.plugin.zsh diff --git a/plugins/cdk/README.md b/plugins/cdk/README.md new file mode 100644 index 000000000..b5c87ee93 --- /dev/null +++ b/plugins/cdk/README.md @@ -0,0 +1,15 @@ +# AWS CDK plugin + +This plugin adds completion for the [AWS Cloud Development Kit (CDK)](https://aws.amazon.com/cdk/) CLI. + +To use it, add `cdk` to the plugins array in your zshrc file: + +```zsh +plugins=(... cdk) +``` + +If the `cdk` command is installed globally, the plugin uses it directly. If `cdk` is not found but `npx` is +available, the plugin defines a `cdk` wrapper that runs `npx -- cdk`, which supports project-local CDK +installations. + +This plugin does not add any aliases. diff --git a/plugins/cdk/cdk.plugin.zsh b/plugins/cdk/cdk.plugin.zsh new file mode 100644 index 000000000..67f8170e2 --- /dev/null +++ b/plugins/cdk/cdk.plugin.zsh @@ -0,0 +1,22 @@ +# AWS CDK plugin +# +# Adds completion for the AWS CDK CLI. If `cdk` is not installed globally but +# `npx` is available, define a wrapper so project-local CDK installations work. + +if (( ! $+commands[cdk] )); then + if (( ! $+commands[npx] )); then + return + fi + + function cdk() { + npx -- cdk "$@" + } +fi + +function _cdk_yargs_completions() { + local -a reply + reply=(${(f)"$(COMP_CWORD="$((CURRENT - 1))" COMP_LINE="$BUFFER" COMP_POINT="$CURSOR" cdk --get-yargs-completions "${words[@]}")"}) + _describe 'values' reply +} + +compdef _cdk_yargs_completions cdk