Przeglądaj źródła

dev: automated commit - 2025-09-29 13:38:09

Mariano Z. 4 miesięcy temu
rodzic
commit
188e601c2e
2 zmienionych plików z 42 dodań i 56 usunięć
  1. 0 1
      local-bin/.local/bin/rmq-passwd
  2. 42 55
      zsh/.config/zsh/completions.zsh

+ 0 - 1
local-bin/.local/bin/rmq-passwd

@@ -18,7 +18,6 @@ kubectl config set-context --current --namespace=oc-app >/dev/null
 password=$(kubectl get secret oc-secrets -o jsonpath="{.data.rabbit_passwd}" | base64 --decode)
 
 printf "$password" | wl-copy
-# printf "$password" | xsel --clipboard
 
 # reset context
 kubectl config use-context $current_context >/dev/null

+ 42 - 55
zsh/.config/zsh/completions.zsh

@@ -1,15 +1,5 @@
 #!/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() {
     local cmd="$1"
     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() {
     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))
 
     if [[ ${#contexts[@]} -gt 0 ]]; then
@@ -45,9 +54,14 @@ _kf_completion() {
     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() {
     local cur prev opts
@@ -61,7 +75,6 @@ _yay_completion() {
     return 0
 }
 
-
 _yay_zsh_completion() {
     local -a opts
     opts=(
@@ -84,37 +97,11 @@ _yay_zsh_completion() {
     _describe 'yay commands' opts
 }
 
-# Enable completion based on shell
+compdef _kf_completion kf
+compdef _rmq_passwd_completion rmq-passwd
+
 if [[ -n "${BASH_VERSION:-}" ]]; then
     complete -F _yay_completion yay
 elif [[ -n "${ZSH_VERSION:-}" ]]; then
     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