kubectl-klock icon indicating copy to clipboard operation
kubectl-klock copied to clipboard

Ability to hide deleted by default

Open zx8 opened this issue 1 year ago • 2 comments

At the moment, whenever I run kubectl klock, I always immediately press d to hide deleted objects, and only show them if needed - 99% of the time I do not want to see the deleted objects.

It would be great if you could either flip the default to hide deleted objects (which I understand is a breaking change), or better yet introduce an environment variable that I can set in my shell startup script, along the lines of KUBECOLOR_HIDE_DELETED_DEFAULT=true.

Thanks for another awesome tool!

zx8 avatar Nov 26 '24 15:11 zx8

Hehe, that environment variable example beginning with KUBECOLOR amuses me :)

This is an excellent suggestion. Personally I'd prefer to see that as a flag, but why not both env var and flag.

applejag avatar Nov 26 '24 17:11 applejag

Hehe, that environment variable example beginning with KUBECOLOR amuses me :)

Haha, habit! Indeed, I meant KLOCK_* 😂

zx8 avatar Nov 26 '24 17:11 zx8

I kind of want to see the deleted pods, but only for a specified amount of time.

So maybe add a command line option to --hide-deleted 20 which removes them after 20 seconds, or --hide-deleted 0s to never show them...

bluegumcity avatar May 21 '25 21:05 bluegumcity

If --hide-deleted 0s means "hide by default" then there's no way of declaring "show deleted forever".

Maybe if it was --hide-deleted -1 to mean forever then we would get around this. But I also like 0 being the default.

This overloading means that I'm more inclined to having 2 configs. Something like --hide-deleted and --hide-deleted-after, though these flags become quite long and get a little annoying to type out manually.

For flags it's also quite common to have the --no- prefix to disable features.

What do you think about having this?

--no-deleted=false       Hide deleted rows by default.
--no-deleted-after=30s   Hide deleted rows after duration. Zero will show forever

This would then be mapped to the following environment variables:

export KLOCK_NO_DELETED="false"
export KLOCK_NO_DELETED_AFTER="30s"

applejag avatar May 24 '25 12:05 applejag

Perfect 👍

zx8 avatar May 24 '25 14:05 zx8

I tinkered around with this idea and got back to your original idea.

Having just one flag is so much more leaner. Like setting both --no-deleted=true and --no-deleted-after=30s at the same time made no sense.

So it's back to --hide-deleted, but it allows a few different permutations:

--hide-deleted=true     same as --hide-deleted=0s
--hide-deleted=0        same as --hide-deleted=0s
--hide-deleted=12m      hides deleted after 12 minutes
--hide-deleted=false    disables auto hiding deleted

applejag avatar May 24 '25 14:05 applejag