Skip to content

Commit aed2c71

Browse files
committed
Improve kl helper
1 parent 5591c62 commit aed2c71

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

.zshrc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ function k8s_namespace() {
503503
}
504504

505505
function k8s_log() {
506-
local resource
506+
local resource follow
507507

508508
if [[ $# -ne 0 ]] ; then
509509
if kubectl get pod "$1" &> /dev/null ; then
@@ -519,6 +519,10 @@ function k8s_log() {
519519
if [[ -z "$resource" ]] ; then
520520
return 1
521521
fi
522+
523+
if [[ $(kubectl get pod "$resource" -o jsonpath='{.status.phase}') == "Running" ]] ; then
524+
follow=1
525+
fi
522526
else
523527
echo "Usage: kl {resource} {option}…"
524528
return 0
@@ -531,7 +535,7 @@ function k8s_log() {
531535
fi
532536

533537
if [[ -f "$HOME/.bin/lj" ]] ; then
534-
if [[ $@ =~ (-F|--follow) ]] ; then
538+
if [[ $@ =~ (-F|--follow) || -n "$follow" ]] ; then
535539
kubectl logs "$resource" -f | lj $@
536540
return $?
537541
else

0 commit comments

Comments
 (0)