From 42d0e12794e2e84370d4d7502d5e6e076625a025 Mon Sep 17 00:00:00 2001 From: Robert Prince Date: Wed, 23 Sep 2020 16:42:42 -0700 Subject: [PATCH 1/5] Add plugin to show Kubernetes pods running in default namespace. Signed-off-by: Robert Prince --- Dev/Kubernetes/k-get-pods.30s.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100755 Dev/Kubernetes/k-get-pods.30s.sh diff --git a/Dev/Kubernetes/k-get-pods.30s.sh b/Dev/Kubernetes/k-get-pods.30s.sh new file mode 100755 index 000000000..a2312b15b --- /dev/null +++ b/Dev/Kubernetes/k-get-pods.30s.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# List running Kubernetes pods (default namespace) +# v1.0 +# Robert Prince +# robertp +# Simple that shows running Kubernetes pods; it's just output from 'kubectl get pods' with a font specified. It assumes you have installed kubectl using brew. +# brew,kubectl + +export PATH=/usr/local/bin:"${PATH}" + +echo "k8s pods" +echo "---" +kubectl get pods | while read -r line; do echo "${line} | font=Menlo"; done From c7713aba26bfdb260fe5c72f8761783a13d2b09f Mon Sep 17 00:00:00 2001 From: Robert Prince Date: Thu, 24 Sep 2020 14:13:40 -0700 Subject: [PATCH 2/5] Nicer display Signed-off-by: Robert Prince --- Dev/Kubernetes/k-get-pods.30s.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Dev/Kubernetes/k-get-pods.30s.sh b/Dev/Kubernetes/k-get-pods.30s.sh index a2312b15b..dd0ac80a0 100755 --- a/Dev/Kubernetes/k-get-pods.30s.sh +++ b/Dev/Kubernetes/k-get-pods.30s.sh @@ -9,6 +9,8 @@ export PATH=/usr/local/bin:"${PATH}" -echo "k8s pods" +numpods=$(kubectl get pods -A 2> /dev/null | grep -v NAME | wc -l) +echo "$numpods pods running" echo "---" -kubectl get pods | while read -r line; do echo "${line} | font=Menlo"; done +if [[ "$numpods" -eq 0 ]]; then exit; fi +kubectl get pods -A | while read -r line; do echo "${line} | font=Menlo"; done From 19a0f32157c98083da92e966610fb3b4ecaf4e31 Mon Sep 17 00:00:00 2001 From: Robert Prince Date: Thu, 24 Sep 2020 14:35:13 -0700 Subject: [PATCH 3/5] Replace iTunes with Music; it just works (tm) Signed-off-by: Robert Prince --- Music/itunes.10s.sh | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Music/itunes.10s.sh b/Music/itunes.10s.sh index 953bcd1eb..497c7fdcc 100755 --- a/Music/itunes.10s.sh +++ b/Music/itunes.10s.sh @@ -1,53 +1,53 @@ -#!/bin/bash +#!/usr/bin/env bash -# Get current iTunes status with play/pause button +# Get current Music status with play/pause button # # based on Spotify script by Jason Tokoph (jason@tokoph.net), # tweaked by Dan Turkel (daturkel@gmail.com), # additionally tweaked by Aleš Farčnik (@alesf) # -# Shows current track information from iTunes +# Shows current track information from Music # 10 second refresh might be a little too quick. Tweak to your liking. # metadata -# iTunes Now Playing +# Music Now Playing # v1.1 -# Dan Turkel, Jason Tokoph, Aleš Farčnik +# Dan Turkel, Jason Tokoph, Aleš Farčnik, Robert Prince # daturkel -# Display currently playing iTunes song with artwork. Play/pause, skip forward, skip backward. +# Display currently playing Music song with artwork. Play/pause, skip forward, skip backward. # http://i.imgur.com/lBfoFdY.png if [ "$1" = 'launch' ]; then - osascript -e 'tell application "iTunes" to activate' + osascript -e 'tell application "Music" to activate' exit fi if [ "$1" = 'open' ]; then - osascript -e 'tell application "iTunes" to reopen' - osascript -e 'tell application "iTunes" to activate' + osascript -e 'tell application "Music" to reopen' + osascript -e 'tell application "Music" to activate' exit fi -if [ "$(osascript -e 'application "iTunes" is running')" = "false" ]; then +if [ "$(osascript -e 'application "Music" is running')" = "false" ]; then echo "♫ | size=12" echo "---" - echo "iTunes is not running" - echo "Launch iTunes | bash='$0' param1=launch terminal=false" + echo "Music is not running" + echo "Launch Music | bash='$0' param1=launch terminal=false" exit fi if [ "$1" = 'playpause' ]; then - osascript -e 'tell application "iTunes" to playpause' + osascript -e 'tell application "Music" to playpause' exit fi if [ "$1" = 'previous' ]; then - osascript -e 'tell application "iTunes" to previous track' + osascript -e 'tell application "Music" to previous track' exit fi if [ "$1" = 'next' ]; then - osascript -e 'tell application "iTunes" to next track'; + osascript -e 'tell application "Music" to next track'; exit fi @@ -66,7 +66,7 @@ fi state=$(osascript -e ' try - tell application "iTunes" + tell application "Music" with timeout 3 seconds player state as string end timeout @@ -78,13 +78,13 @@ end try if [ "$state" = "not available" ]; then echo "♫ | size=12" echo "---" - echo "iTunes is not available" + echo "Music is not available" exit fi track=$(osascript -e' try -tell application "iTunes" to name of current track as string +tell application "Music" to name of current track as string on error errText "no track selected" end try @@ -92,7 +92,7 @@ end try artist=$(osascript -e' try - tell application "iTunes" to artist of current track as string + tell application "Music" to artist of current track as string on error errText "" end try @@ -100,7 +100,7 @@ end try album=$(osascript -e' try - tell application "iTunes" to album of current track as string + tell application "Music" to album of current track as string on error errText "" end try @@ -108,7 +108,7 @@ end try tmp_file=$(osascript -e' try - tell application "iTunes" + tell application "Music" tell artwork 1 of current track if format is JPEG picture then set imgFormat to ".jpg" @@ -132,7 +132,7 @@ end try if [ ! -f "$tmp_file" ]; then osascript -e' try - tell application "iTunes" + tell application "Music" tell artwork 1 of current track set srcBytes to raw data if format is JPEG picture then From adb0d0ad2b6f38a5dddbcdf411e1d3c2a7c42ff1 Mon Sep 17 00:00:00 2001 From: Robert Prince Date: Thu, 24 Sep 2020 19:41:08 -0700 Subject: [PATCH 4/5] Revert "Replace iTunes with Music; it just works (tm)" This reverts commit 19a0f32157c98083da92e966610fb3b4ecaf4e31. --- Music/itunes.10s.sh | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Music/itunes.10s.sh b/Music/itunes.10s.sh index 497c7fdcc..953bcd1eb 100755 --- a/Music/itunes.10s.sh +++ b/Music/itunes.10s.sh @@ -1,53 +1,53 @@ -#!/usr/bin/env bash +#!/bin/bash -# Get current Music status with play/pause button +# Get current iTunes status with play/pause button # # based on Spotify script by Jason Tokoph (jason@tokoph.net), # tweaked by Dan Turkel (daturkel@gmail.com), # additionally tweaked by Aleš Farčnik (@alesf) # -# Shows current track information from Music +# Shows current track information from iTunes # 10 second refresh might be a little too quick. Tweak to your liking. # metadata -# Music Now Playing +# iTunes Now Playing # v1.1 -# Dan Turkel, Jason Tokoph, Aleš Farčnik, Robert Prince +# Dan Turkel, Jason Tokoph, Aleš Farčnik # daturkel -# Display currently playing Music song with artwork. Play/pause, skip forward, skip backward. +# Display currently playing iTunes song with artwork. Play/pause, skip forward, skip backward. # http://i.imgur.com/lBfoFdY.png if [ "$1" = 'launch' ]; then - osascript -e 'tell application "Music" to activate' + osascript -e 'tell application "iTunes" to activate' exit fi if [ "$1" = 'open' ]; then - osascript -e 'tell application "Music" to reopen' - osascript -e 'tell application "Music" to activate' + osascript -e 'tell application "iTunes" to reopen' + osascript -e 'tell application "iTunes" to activate' exit fi -if [ "$(osascript -e 'application "Music" is running')" = "false" ]; then +if [ "$(osascript -e 'application "iTunes" is running')" = "false" ]; then echo "♫ | size=12" echo "---" - echo "Music is not running" - echo "Launch Music | bash='$0' param1=launch terminal=false" + echo "iTunes is not running" + echo "Launch iTunes | bash='$0' param1=launch terminal=false" exit fi if [ "$1" = 'playpause' ]; then - osascript -e 'tell application "Music" to playpause' + osascript -e 'tell application "iTunes" to playpause' exit fi if [ "$1" = 'previous' ]; then - osascript -e 'tell application "Music" to previous track' + osascript -e 'tell application "iTunes" to previous track' exit fi if [ "$1" = 'next' ]; then - osascript -e 'tell application "Music" to next track'; + osascript -e 'tell application "iTunes" to next track'; exit fi @@ -66,7 +66,7 @@ fi state=$(osascript -e ' try - tell application "Music" + tell application "iTunes" with timeout 3 seconds player state as string end timeout @@ -78,13 +78,13 @@ end try if [ "$state" = "not available" ]; then echo "♫ | size=12" echo "---" - echo "Music is not available" + echo "iTunes is not available" exit fi track=$(osascript -e' try -tell application "Music" to name of current track as string +tell application "iTunes" to name of current track as string on error errText "no track selected" end try @@ -92,7 +92,7 @@ end try artist=$(osascript -e' try - tell application "Music" to artist of current track as string + tell application "iTunes" to artist of current track as string on error errText "" end try @@ -100,7 +100,7 @@ end try album=$(osascript -e' try - tell application "Music" to album of current track as string + tell application "iTunes" to album of current track as string on error errText "" end try @@ -108,7 +108,7 @@ end try tmp_file=$(osascript -e' try - tell application "Music" + tell application "iTunes" tell artwork 1 of current track if format is JPEG picture then set imgFormat to ".jpg" @@ -132,7 +132,7 @@ end try if [ ! -f "$tmp_file" ]; then osascript -e' try - tell application "Music" + tell application "iTunes" tell artwork 1 of current track set srcBytes to raw data if format is JPEG picture then From 26fe42f40ba4d683441f2e53175c12cb78774a9a Mon Sep 17 00:00:00 2001 From: Robert Prince Date: Fri, 11 Dec 2020 10:01:10 -0800 Subject: [PATCH 5/5] update a bit, add image --- Dev/Kubernetes/k-get-pods.30s.sh | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/Dev/Kubernetes/k-get-pods.30s.sh b/Dev/Kubernetes/k-get-pods.30s.sh index dd0ac80a0..cab2a0eee 100755 --- a/Dev/Kubernetes/k-get-pods.30s.sh +++ b/Dev/Kubernetes/k-get-pods.30s.sh @@ -1,16 +1,31 @@ #!/usr/bin/env bash -# List running Kubernetes pods (default namespace) +# List some running Kubernetes things # v1.0 # Robert Prince # robertp -# Simple that shows running Kubernetes pods; it's just output from 'kubectl get pods' with a font specified. It assumes you have installed kubectl using brew. +# Simple plugin that shows running Kubernetes pods, services, deployments, ... # brew,kubectl +# https://i.imgur.com/sH9yhBW.png export PATH=/usr/local/bin:"${PATH}" -numpods=$(kubectl get pods -A 2> /dev/null | grep -v NAME | wc -l) -echo "$numpods pods running" +numpods=$(kubectl get pods -A 2> /dev/null | grep -v NAME | wc -l | sed 's/ //g') +numsvc=$(kubectl get services -A 2> /dev/null | grep -v NAME | wc -l | sed 's/ //g') +numdeps=$(kubectl get deployments -A 2> /dev/null | grep -v NAME | wc -l | sed 's/ //g') + +# if [[ "$numpods" -eq "0" && "$numsvc" -eq "0" && "$numdeps" -eq "0" ]]; then echo "no k8s"; exit; fi + +if [[ "$numpods" -eq "0" && "$numsvc" -eq "0" && "$numdeps" -eq "0" ]]; then exit; fi + +echo "[$numpods pods / $numsvc services / $numdeps deployments]" + echo "---" -if [[ "$numpods" -eq 0 ]]; then exit; fi +echo "==== PODS ====" kubectl get pods -A | while read -r line; do echo "${line} | font=Menlo"; done +echo "---" +echo "==== SERVICES ====" +kubectl get services -A | while read -r line; do echo "${line} | font=Menlo"; done +echo "---" +echo "==== DEPLOYMENTS ====" +kubectl get deployments -A | while read -r line; do echo "${line} | font=Menlo"; done