|
@@ -1,15 +1,5 @@
|
|
|
#!/bin/zsh
|
|
#!/bin/zsh
|
|
|
-# Completion registration file
|
|
|
|
|
-# This file handles all completion registrations
|
|
|
|
|
|
|
|
|
|
-# Load custom completion files
|
|
|
|
|
-for completion_file in ~/.local/share/zsh/*-autocomplete.zsh(N); do
|
|
|
|
|
- if [ -f "$completion_file" ]; then
|
|
|
|
|
- source "$completion_file"
|
|
|
|
|
- fi
|
|
|
|
|
-done
|
|
|
|
|
-
|
|
|
|
|
-# Lazy loading function for completions
|
|
|
|
|
_lazy_load_completion() {
|
|
_lazy_load_completion() {
|
|
|
local cmd="$1"
|
|
local cmd="$1"
|
|
|
local completion_cmd="$2"
|
|
local completion_cmd="$2"
|
|
@@ -21,23 +11,42 @@ _lazy_load_completion() {
|
|
|
}"
|
|
}"
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-# Load lightweight completions immediately
|
|
|
|
|
-if command -v eza &> /dev/null; then compdef eza=ls; fi
|
|
|
|
|
|
|
+for completion_file in ~/.local/share/zsh/*-autocomplete.zsh(N); do
|
|
|
|
|
+ if [ -f "$completion_file" ]; then
|
|
|
|
|
+ source "$completion_file"
|
|
|
|
|
+ fi
|
|
|
|
|
+done
|
|
|
|
|
+
|
|
|
|
|
+if command -v eza &> /dev/null; then
|
|
|
|
|
+ compdef eza=ls
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+if command -v kubefwd &> /dev/null; then
|
|
|
|
|
+ _lazy_load_completion kubefwd "kubefwd completion zsh"
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+if command -v bombadil &> /dev/null; then
|
|
|
|
|
+ _lazy_load_completion bombadil "bombadil generate-completions zsh"
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+if command -v rop &> /dev/null; then
|
|
|
|
|
+ eval "$(rop completion zsh)"
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+if command -v goq &> /dev/null; then
|
|
|
|
|
+ eval "$(goq completion zsh)"
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
-# Defer heavy completions with lazy loading
|
|
|
|
|
-if command -v kubefwd &> /dev/null; then _lazy_load_completion kubefwd "kubefwd completion zsh"; fi
|
|
|
|
|
-if command -v bombadil &> /dev/null; then _lazy_load_completion bombadil "bombadil generate-completions zsh"; fi
|
|
|
|
|
|
|
+if command -v drop &> /dev/null; then
|
|
|
|
|
+ eval "$(drop completion zsh)"
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
-# Load remaining completions normally (they're lightweight)
|
|
|
|
|
-if command -v rop &> /dev/null; then eval "$(rop completion zsh)"; fi
|
|
|
|
|
-if command -v goq &> /dev/null; then eval "$(goq completion zsh)"; fi
|
|
|
|
|
-if command -v drop &> /dev/null; then eval "$(drop completion zsh)"; fi
|
|
|
|
|
-if command -v mora &> /dev/null; then eval "$(mora completion zsh)"; fi
|
|
|
|
|
|
|
+if command -v mora &> /dev/null; then
|
|
|
|
|
+ eval "$(mora completion zsh)"
|
|
|
|
|
+fi
|
|
|
|
|
|
|
|
-# Custom completion for kf function using kubectx contexts
|
|
|
|
|
_kf_completion() {
|
|
_kf_completion() {
|
|
|
local -a contexts
|
|
local -a contexts
|
|
|
- # Get all contexts and extract unique cluster names (remove -read and -security suffixes)
|
|
|
|
|
contexts=($(kubectx 2>/dev/null | sed 's/-read$//; s/-security$//' | sort -u))
|
|
contexts=($(kubectx 2>/dev/null | sed 's/-read$//; s/-security$//' | sort -u))
|
|
|
|
|
|
|
|
if [[ ${#contexts[@]} -gt 0 ]]; then
|
|
if [[ ${#contexts[@]} -gt 0 ]]; then
|
|
@@ -45,9 +54,14 @@ _kf_completion() {
|
|
|
fi
|
|
fi
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-# Register the completion
|
|
|
|
|
-compdef _kf_completion kf
|
|
|
|
|
|
|
+_rmq_passwd_completion() {
|
|
|
|
|
+ local -a environments
|
|
|
|
|
+ environments=($(kubectl config get-contexts -o name 2>/dev/null | grep '^oc-.*-eks-cluster$' | sed 's/^oc-//; s/-eks-cluster$//' | sort -u))
|
|
|
|
|
|
|
|
|
|
+ if [[ ${#environments[@]} -gt 0 ]]; then
|
|
|
|
|
+ _describe 'environments' environments
|
|
|
|
|
+ fi
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
_yay_completion() {
|
|
_yay_completion() {
|
|
|
local cur prev opts
|
|
local cur prev opts
|
|
@@ -61,7 +75,6 @@ _yay_completion() {
|
|
|
return 0
|
|
return 0
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-
|
|
|
|
|
_yay_zsh_completion() {
|
|
_yay_zsh_completion() {
|
|
|
local -a opts
|
|
local -a opts
|
|
|
opts=(
|
|
opts=(
|
|
@@ -84,37 +97,11 @@ _yay_zsh_completion() {
|
|
|
_describe 'yay commands' opts
|
|
_describe 'yay commands' opts
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-# Enable completion based on shell
|
|
|
|
|
|
|
+compdef _kf_completion kf
|
|
|
|
|
+compdef _rmq_passwd_completion rmq-passwd
|
|
|
|
|
+
|
|
|
if [[ -n "${BASH_VERSION:-}" ]]; then
|
|
if [[ -n "${BASH_VERSION:-}" ]]; then
|
|
|
complete -F _yay_completion yay
|
|
complete -F _yay_completion yay
|
|
|
elif [[ -n "${ZSH_VERSION:-}" ]]; then
|
|
elif [[ -n "${ZSH_VERSION:-}" ]]; then
|
|
|
compdef _yay_zsh_completion yay
|
|
compdef _yay_zsh_completion yay
|
|
|
-fi
|
|
|
|
|
-
|
|
|
|
|
-_use_node_completion() {
|
|
|
|
|
- local -a versions
|
|
|
|
|
- local script_dir=""
|
|
|
|
|
-
|
|
|
|
|
- # Find the script directory
|
|
|
|
|
- if [ -f "./use-node.sh" ]; then
|
|
|
|
|
- script_dir="."
|
|
|
|
|
- else
|
|
|
|
|
- # Find the actual script location
|
|
|
|
|
- script_dir="$(dirname "$(readlink -f ~/.local/bin/use-node 2>/dev/null || echo ~/.local/bin/use-node)")"
|
|
|
|
|
- fi
|
|
|
|
|
-
|
|
|
|
|
- # Get versions from nodejs-* directories only
|
|
|
|
|
- if [ -d "$script_dir" ]; then
|
|
|
|
|
- versions=($(find "$script_dir" -maxdepth 1 -type d -name "nodejs-*" 2>/dev/null | sed 's/.*nodejs-/node@/'))
|
|
|
|
|
- fi
|
|
|
|
|
-
|
|
|
|
|
- if [[ ${#versions[@]} -gt 0 ]]; then
|
|
|
|
|
- _describe 'node versions' versions
|
|
|
|
|
- fi
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-# Register the completion
|
|
|
|
|
-compdef _use_node_completion ./use-node.sh
|
|
|
|
|
-compdef _use_node_completion use-node.sh
|
|
|
|
|
-compdef _use_node_completion use-node
|
|
|
|
|
-
|
|
|
|
|
|
|
+fi
|