Open
Conversation
Signed-off-by: pasteley <ceasebeing@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add support for restoring the last-used context across shell sessions:
Closes: #88
What's added
kubie ctx --last-usedcli argument: attempts to restore the most recently used context from kubie state.behavior.track_last_usedconfig option: when enabled, kubie records the last successfully entered context into the state file on every successful context entry.Motiviation
Automatically re-enter context used most recently (without interacting with the context selector) on new terminal sessions (e.g. zsh init).
This PR provides:
--last-used(safe to call from shell init)behavior.track_last_context(keeps default behavior unchanged)How it works
Recording
When
behavior.track_last_used: true, kubie updates state on each successfulkubie ctx ...entry:state.last_context = <resolved context name>This happens regardless of whether the context was chosen via selector or passed positionally.
Restoring
When
kubie ctx --last-usedis called:state.last_contextkubie ctx --last-used <context>behaves likekubie ctx <context>(explicit context wins); the flag only affects whether restore-from-state is attempted.Typical usage (in shell init)