We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5591c62 commit aed2c71Copy full SHA for aed2c71
1 file changed
.zshrc
@@ -503,7 +503,7 @@ function k8s_namespace() {
503
}
504
505
function k8s_log() {
506
- local resource
+ local resource follow
507
508
if [[ $# -ne 0 ]] ; then
509
if kubectl get pod "$1" &> /dev/null ; then
@@ -519,6 +519,10 @@ function k8s_log() {
519
if [[ -z "$resource" ]] ; then
520
return 1
521
fi
522
+
523
+ if [[ $(kubectl get pod "$resource" -o jsonpath='{.status.phase}') == "Running" ]] ; then
524
+ follow=1
525
+ fi
526
else
527
echo "Usage: kl {resource} {option}…"
528
return 0
@@ -531,7 +535,7 @@ function k8s_log() {
531
535
532
536
533
537
if [[ -f "$HOME/.bin/lj" ]] ; then
534
- if [[ $@ =~ (-F|--follow) ]] ; then
538
+ if [[ $@ =~ (-F|--follow) || -n "$follow" ]] ; then
539
kubectl logs "$resource" -f | lj $@
540
return $?
541
0 commit comments