Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
7ae4f76f
Unverified
Commit
7ae4f76f
authored
Jan 05, 2022
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor(kubectl): optimize completion generation
parent
d3bb52d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
14 deletions
+24
-14
kubectl.plugin.zsh
plugins/kubectl/kubectl.plugin.zsh
+24
-14
No files found.
plugins/kubectl/kubectl.plugin.zsh
View file @
7ae4f76f
if
((
$+
commands[kubectl]
))
;
then
if
((
$+
commands[kubectl]
))
;
then
__KUBECTL_COMPLETION_FILE
=
"
${
ZSH_CACHE_DIR
}
/kubectl_completion"
# TODO: 2022-01-05: remove this block
# remove old generated files
if
[[
!
-f
$__KUBECTL_COMPLETION_FILE
||
!
-s
$__KUBECTL_COMPLETION_FILE
]]
;
then
command rm
-f
"
$ZSH_CACHE_DIR
/kubectl_completion"
kubectl completion zsh
>!
$__KUBECTL_COMPLETION_FILE
fi
# TODO: 2022-01-05: remove this bit of code as it exists in oh-my-zsh.sh
# Add completions folder in $ZSH_CACHE_DIR
[[
-f
$__KUBECTL_COMPLETION_FILE
]]
&&
source
$__KUBECTL_COMPLETION_FILE
command mkdir
-p
"
$ZSH_CACHE_DIR
/completions"
((
${
fpath
[(Ie)
"
$ZSH_CACHE_DIR
/completions"
]
}
))
||
fpath
=(
"
$ZSH_CACHE_DIR
/completions"
$fpath
)
unset
__KUBECTL_COMPLETION_FILE
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `kubectl`. Otherwise, compinit will have already done that.
if
[[
!
-f
"
$ZSH_CACHE_DIR
/completions/_kubectl"
]]
;
then
typeset
-g
-A
_comps
autoload
-Uz
_kubectl
_comps[kubectl]
=
_kubectl
fi
kubectl completion zsh
>!
"
$ZSH_CACHE_DIR
/completions/_kubectl"
&|
fi
fi
# This command is used a LOT both below and in daily life
# This command is used a LOT both below and in daily life
...
@@ -97,8 +106,9 @@ alias kdd='kubectl describe deployment'
...
@@ -97,8 +106,9 @@ alias kdd='kubectl describe deployment'
alias
kdeld
=
'kubectl delete deployment'
alias
kdeld
=
'kubectl delete deployment'
alias
ksd
=
'kubectl scale deployment'
alias
ksd
=
'kubectl scale deployment'
alias
krsd
=
'kubectl rollout status deployment'
alias
krsd
=
'kubectl rollout status deployment'
kres
(){
kubectl
set env
$@
REFRESHED_AT
=
$(
date
+%Y%m%d%H%M%S
)
function
kres
(){
kubectl
set env
$@
REFRESHED_AT
=
$(
date
+%Y%m%d%H%M%S
)
}
}
# Rollout management.
# Rollout management.
...
@@ -170,9 +180,9 @@ alias kdelcj='kubectl delete cronjob'
...
@@ -170,9 +180,9 @@ alias kdelcj='kubectl delete cronjob'
# Only run if the user actually has kubectl installed
# Only run if the user actually has kubectl installed
if
((
${
+_comps[kubectl]
}
))
;
then
if
((
${
+_comps[kubectl]
}
))
;
then
kj
()
{
kubectl
"
$@
"
-o
json | jq
;
}
function
kj
()
{
kubectl
"
$@
"
-o
json | jq
;
}
kjx
()
{
kubectl
"
$@
"
-o
json | fx
;
}
function
kjx
()
{
kubectl
"
$@
"
-o
json | fx
;
}
ky
()
{
kubectl
"
$@
"
-o
yaml | yh
;
}
function
ky
()
{
kubectl
"
$@
"
-o
yaml | yh
;
}
compdef
kj
=
kubectl
compdef
kj
=
kubectl
compdef
kjx
=
kubectl
compdef
kjx
=
kubectl
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment