feat(fish): save installed plugins and update fish.config
This commit is contained in:
21
fish/completions/user/ksecret.fish
Normal file
21
fish/completions/user/ksecret.fish
Normal file
@@ -0,0 +1,21 @@
|
||||
# Vervollständige Secret-Namen aus aktuellem oder gegebenem Namespace
|
||||
function __ksecret_list_secrets
|
||||
set -l ns (commandline -opc | grep -oE '\-n\s+\S+' | awk '{print $2}')
|
||||
if test -n "$ns"
|
||||
kubectl get secrets -n $ns -o json | jq -r '.items[].metadata.name'
|
||||
else
|
||||
kubectl get secrets -o json | jq -r '.items[].metadata.name'
|
||||
end
|
||||
end
|
||||
|
||||
# Vervollständige Namespace-Namen
|
||||
function __ksecret_list_namespaces
|
||||
kubectl get ns -o json | jq -r '.items[].metadata.name'
|
||||
end
|
||||
|
||||
# Vervollständigung für secret-name (erstes Argument)
|
||||
complete -c ksecret -n '__fish_use_subcommand' -a '(__ksecret_list_secrets)' -f -d "Secret name"
|
||||
|
||||
# Vervollständigung für -n (Namespace-Flag)
|
||||
complete -c ksecret -s n -l namespace -x -a '(__ksecret_list_namespaces)' -d "Namespace"
|
||||
|
||||
@@ -22,3 +22,15 @@ zoxide init fish | source
|
||||
alias rm "trash -v"
|
||||
alias ll "eza -l"
|
||||
alias ls "eza"
|
||||
|
||||
for f in ~/.config/fish/functions/user/*.fish
|
||||
source $f
|
||||
end
|
||||
|
||||
for f in ~/.config/fish/completions/user/*.fish
|
||||
source $f
|
||||
end
|
||||
|
||||
# Enable starship
|
||||
starship init fish | source
|
||||
|
||||
|
||||
4
fish/fish_plugins
Normal file
4
fish/fish_plugins
Normal file
@@ -0,0 +1,4 @@
|
||||
jorgebucaran/fisher
|
||||
patrickf1/fzf.fish
|
||||
jorgebucaran/nvm.fish
|
||||
jethrokuan/z
|
||||
48
fish/functions/user/ksecret.fish
Normal file
48
fish/functions/user/ksecret.fish
Normal file
@@ -0,0 +1,48 @@
|
||||
function ksecret
|
||||
set -l namespace ""
|
||||
set -l secret_name ""
|
||||
|
||||
# Manuelles Argument-Parsen
|
||||
while set -q argv[1]
|
||||
switch $argv[1]
|
||||
case -n
|
||||
if not set -q argv[2]
|
||||
echo "Error: Missing namespace after -n" >&2
|
||||
return 1
|
||||
end
|
||||
set namespace $argv[2]
|
||||
set argv $argv[3..-1]
|
||||
case --help -h
|
||||
echo "Usage: ksecret <secret-name> [-n <namespace>]"
|
||||
return 0
|
||||
case '*'
|
||||
if test -z "$secret_name"
|
||||
set secret_name $argv[1]
|
||||
set argv $argv[2..-1]
|
||||
else
|
||||
echo "Error: Unknown argument $argv[1]" >&2
|
||||
return 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if test -z "$secret_name"
|
||||
echo "Error: secret name is required" >&2
|
||||
return 1
|
||||
end
|
||||
|
||||
if test -n "$namespace"
|
||||
if not kubectl get namespace "$namespace" > /dev/null 2>&1
|
||||
echo "Error: Namespace '$namespace' does not exist" >&2
|
||||
return 1
|
||||
end
|
||||
kubectl get secret $secret_name -n $namespace -o json | jq -r '
|
||||
.data | to_entries[] | "\(.key): \(.value | @base64d)"
|
||||
'
|
||||
else
|
||||
kubectl get secret $secret_name -o json | jq -r '
|
||||
.data | to_entries[] | "\(.key): \(.value | @base64d)"
|
||||
'
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user