Skip to content

Instantly share code, notes, and snippets.

@caruccio
Created May 12, 2024 18:47
Show Gist options
  • Save caruccio/fc182fb4e8b03257ea30682eb91db7ee to your computer and use it in GitHub Desktop.
Save caruccio/fc182fb4e8b03257ea30682eb91db7ee to your computer and use it in GitHub Desktop.
Example kubectl plugin
#!/bin/bash
ContainerCreating=$(tput setaf 13) # magenta
Pending=$(tput setaf 3) # yellow
Running=$(tput setaf 2) # green
Error=$(tput setaf 1) # red
BackOf="$Error"
Terminating=$(tput setaf 8) # gray
Finished="$Terminating"
Completed="$Terminating"
Reset=$(tput sgr0)
kubectl $@ \
| sed -e "s/\(.*Pending.*\)/${Pending}\1${reset}/" \
-e "s/\(.*ContainerCreating.*\)/${ContainerCreating}\1${reset}/" \
-e "s/\(.*Running.*\)/${Running}\1${reset}/" \
-e "s/\(.*Error.*\)/${Error}\1${reset}/" \
-e "s/\(.*BackOf.*\)/${BackOf}\1${reset}/" \
-e "s/\(.*Terminating.*\)/${Terminating}\1${reset}/" \
-e "s/\(.*Finished.*\)/${Finished}\1${reset}/" \
-e "s/\(.*Completed.*\)/${Completed}\1${reset}/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment