mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
Update help/example for kubectl completion
This commit is contained in:
parent
70b942d663
commit
0153f8de1a
@ -50,40 +50,37 @@ var (
|
|||||||
completion of kubectl commands. This can be done by sourcing it from
|
completion of kubectl commands. This can be done by sourcing it from
|
||||||
the .bash_profile.
|
the .bash_profile.
|
||||||
|
|
||||||
Note: this requires the bash-completion framework, which is not installed
|
Detailed instructions on how to do this are available here:
|
||||||
by default on Mac. This can be installed by using homebrew:
|
https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion
|
||||||
|
|
||||||
$ brew install bash-completion
|
|
||||||
|
|
||||||
Once installed, bash_completion must be evaluated. This can be done by adding the
|
|
||||||
following line to the .bash_profile
|
|
||||||
|
|
||||||
$ source $(brew --prefix)/etc/bash_completion
|
|
||||||
|
|
||||||
Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2`))
|
Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2`))
|
||||||
|
|
||||||
completion_example = templates.Examples(i18n.T(`
|
completion_example = templates.Examples(i18n.T(`
|
||||||
# Install bash completion on a Mac using homebrew
|
# Installing bash completion on macOS using homebrew
|
||||||
brew install bash-completion
|
## If running Bash 3.2 included with macOS
|
||||||
printf "
|
brew install bash-completion
|
||||||
# Bash completion support
|
## or, if running Bash 4.1+
|
||||||
source $(brew --prefix)/etc/bash_completion
|
brew install bash-completion@2
|
||||||
" >> $HOME/.bash_profile
|
## If kubectl is installed via homebrew, this should start working immediately.
|
||||||
source $HOME/.bash_profile
|
## If you've installed via other means, you may need add the completion to your completion directory
|
||||||
|
kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
|
||||||
|
|
||||||
# Load the kubectl completion code for bash into the current shell
|
|
||||||
source <(kubectl completion bash)
|
|
||||||
|
|
||||||
# Write bash completion code to a file and source if from .bash_profile
|
# Installing bash completion on Linux
|
||||||
kubectl completion bash > ~/.kube/completion.bash.inc
|
## Load the kubectl completion code for bash into the current shell
|
||||||
printf "
|
source <(kubectl completion bash)
|
||||||
# Kubectl shell completion
|
## Write bash completion code to a file and source if from .bash_profile
|
||||||
source '$HOME/.kube/completion.bash.inc'
|
kubectl completion bash > ~/.kube/completion.bash.inc
|
||||||
" >> $HOME/.bash_profile
|
printf "
|
||||||
source $HOME/.bash_profile
|
# Kubectl shell completion
|
||||||
|
source '$HOME/.kube/completion.bash.inc'
|
||||||
|
" >> $HOME/.bash_profile
|
||||||
|
source $HOME/.bash_profile
|
||||||
|
|
||||||
# Load the kubectl completion code for zsh[1] into the current shell
|
# Load the kubectl completion code for zsh[1] into the current shell
|
||||||
source <(kubectl completion zsh)`))
|
source <(kubectl completion zsh)
|
||||||
|
# Set the kubectl completion code for zsh[1] to autoload on startup
|
||||||
|
kubectl completion zsh > "${fpath[1]}/_kubectl"`))
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -141,8 +138,8 @@ func runCompletionBash(out io.Writer, boilerPlate string, kubectl *cobra.Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
func runCompletionZsh(out io.Writer, boilerPlate string, kubectl *cobra.Command) error {
|
func runCompletionZsh(out io.Writer, boilerPlate string, kubectl *cobra.Command) error {
|
||||||
zsh_head := `#compdef kubectl
|
zsh_head := "#compdef kubectl\n"
|
||||||
`
|
|
||||||
out.Write([]byte(zsh_head))
|
out.Write([]byte(zsh_head))
|
||||||
|
|
||||||
if len(boilerPlate) == 0 {
|
if len(boilerPlate) == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user