kubectx icon indicating copy to clipboard operation
kubectx copied to clipboard

Feature request: browse context history

Open ryanmcnamara opened this issue 9 months ago • 2 comments

kubectx -

which is documented here

I: kubectx -h
USAGE:
  kubectx                       : list the contexts
  kubectx <NAME>                : switch to context <NAME>
  kubectx -                     : switch to the previous context
  kubectx -c, --current         : show the current context name
  ...

Is great for switching to the previous context. What I would like is to be able to see the previous n contexts and choose between them. Perhaps a new flag could be created something like kubectx --history?

For my own personal use I plan to set it up to have kubectx or an alias default to this most recent ordering (contexts not in the history at all would come last)

Open to other suggestions / workarounds as well!

ryanmcnamara avatar Jul 08 '25 18:07 ryanmcnamara

Why not just use your shell history (Ctrl+R) like you would for any other command, like "cd" or "git checkout"?

Or are you only proposing we change the ordering that we present to the interactive selection (the fzf command)?

ahmetb avatar Aug 23 '25 17:08 ahmetb

Hi @ahmetb When I use kubectx with fzf, the only entry in my shells history file is kubectx, so Ctrl r won't work

I'm just proposing some way that kubectx could show users their recent contexts. I was just trying to give motivation for how I would use it.

ryanmcnamara avatar Aug 23 '25 18:08 ryanmcnamara