-
Notifications
You must be signed in to change notification settings - Fork 924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ANSI colors to kubectl describe and other outputs #524
Comments
Maybe a good idea |
/kind feature |
Specifically I would expect colorization on kubectl get -o json $type $name | jq . |
@jglick as a work around you can use something like https://www.npmjs.com/package/cli-highlight then run:
That's what I do currently :) |
You could also use
since that is a lot to type, you may want to wrap that in a bash function
then you can simply pipe to the function
|
This would be really helpful to see the difference between "Pending" and "Running" on
|
It would be great to highlight pods in "kubectl get pods" where # of ready containers < total # of containers |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
This would be so helpful. Anyone working on a PR for this? |
Having colorized output for kubectl get nodes would be fantastically helpful. |
@geekofalltrades I use this: save it as a file lets say k8s_color and then:
I know its not elegant solution but it gets the job done |
Any news on this? |
As a work around you can use bat then run: $ kubectl get pods -o yaml | bat -l yaml |
Another weird work around
It would be great if someone writes a "kubernetes plugin" for CCZE :) |
Or in alternative you could try yh for YAML output
|
This issue is opened for almost 2 years. Is it on the roadmap? |
I am currently using zsh instead of bash and antigen to manage zsh "plugins", one of them is "antigen bundle c-castillo/ccze" which resides in github.com/c-castillo/ccze for kubectl get X color I have added the jq plugin to zsh so I use kubectl "-o json" and then press ALT-J and I Can see the colors for the json output of kubectl command, and to stuff with it using jq. maybe yq can be added to the mix @andreazorzetto I think it would be nice to start from there since handy shortcuts can be made and kubectl can be added to a list of commands ccze can process, thought I haven't checked how it manages the rules for the coloring. here's my current .zshrc : source ~/antigen.zsh
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle reegnz/jq-zsh-plugin
antigen bundle c-castillo/ccze
export PATH=/snap/bin:$PATH
set -g mouse on
powerline-daemon -q
#tmux new
source /usr/share/powerline/bindings/zsh/powerline.zsh
POWERLINE_CONFIG_COMMAND=powerline-config
#powerline-config tmux setup
# Set up the prompt
source /usr/share/powerlevel9k/powerlevel9k.zsh-theme
autoload -Uz promptinit
promptinit
prompt adam1
setopt histignorealldups sharehistory
# Use emacs keybindings even if our EDITOR is set to vi
bindkey "\033[1~" beginning-of-line
bindkey "\033[4~" end-of-line
# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=1000
SAVEHIST=10000
HISTFILE=~/.zsh_history
# Use modern completion system
autoload -Uz compinit
compinit
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
antigen apply |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/remove-lifecycle stale |
Just FYI I've made a CLI tool to do this. |
This feature should be built-in. but in any case, is a good hack, thanks @WladyX Best Regards, |
/assign |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
/remove-lifecycle stale |
Sharing trick based on @spuder comment earlier but using bat: A cat(1) clone with wings. kubectl get $type $name -oyaml | cat -l yaml --paging=never Alias function vml() {
cat -l yaml --paging=never
}
Output PS: this is using gruvbox-dark theme from bat. |
For reference, here's the new maintained one: https://github.com/kubecolor/kubecolor |
Maybe the answer we are looking for here is the ability to locally remap kubectl commands. Consider:
The ability to generically override commands as a part of the login context would cover these bases. A service account with no overrides would get raw output, users who had customizations would get their preferred output format without having to use a different command set. A final tweak on this would be to allow krew to update the override config. So if someone installed |
Honestly, I think that's overengineering. kubectl itself could output colors based on whether it is running in a terminal with color support or not. Like bat itself, which automatically disables color when being executed in things like pipes. |
Point taken, but one may want a completely different output for the same basic commands. |
side wish,
kinda wished that* kubectl describe *allowed output format, so that it
can be piped to a any syntax highlighter
…On Thu, Apr 18, 2024 at 1:33 PM Brian Topping ***@***.***> wrote:
kubectl itself could output colors based on whether it is running in a
terminal with color support or not
Point taken, but one may want a completely different output for the same
basic commands.
—
Reply to this email directly, view it on GitHub
<#524 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AET32OXYPVUKJ7RW2I3A3HLY6AUZDAVCNFSM4FRPBD42U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBWGUZDMOJQGEYQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues. This bot triages un-triaged issues according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
/remove-lifecycle rotten |
FEATURE REQUEST:
Currently kubectl outputs are pretty boring without a color:
Adding color to them will make them easier to read. Each key could be colored based on its indentation level. Each key/value pair in labels,annotations,taints etc could be colored differently as well.
The text was updated successfully, but these errors were encountered: