Closed brenix closed 2 months ago
Is the context tied to a session? If you need to change the context when you switch sessions then the startup_command
approach on a custom config makes sense.
But if you're just wanting to change contexts in general I don't think sesh is the right solution. For now, I'd like sesh to only deal with sessions, I think adding non-session related logic would complicated the project's structure.
But I do like the idea of more programatic configuration, so if I experiment with that idea I will let you know. But ultimately the entry you select would create or switch to a tmux session
What would you like sesh to do?
I've started using sesh in particular with its integration with zoxide and tmux which works great and helps with context switching on the CLI.
I switch kubernetes contexts very often. While there are many tools to do this, they only set the current context for the CLI session that you are on. Things get ugly when I have multiple panes or windows with different contexts set, so having them in separate tmux sessions is much more efficient. Therefore, I wanted to have the same context switching that sesh provides in tmux, but for kubectl contexts.
My solution to this for the time being is to add a several sessions to the sesh config with a startup command to set the
KUBECONFIG
environment variable. However, I think it would be awesome to have sesh support these out of the box like it does with zoxide. This would require parsing the yaml files under.kube
and grabbing the contexts from there, similarly to how tools like kubectx does.While this is just one feature, it also made me think that it might be cool to have sesh support custom lists (perhaps in the config file). As an example, one could create a custom command to provide a list of strings, so that when you run
sesh list
, it would show the resulting list of strings there. From that you can have a similar key for a startup command to run for that custom list. An example of this could look like:[[list]] name = "kubeconfigs" path = "~" icon = "" command = "fd . ~/.kube -d 1 -t f -e yaml -e yml" startup_command = "export KUBECONFIG={{result}}"
I use direnv
for this, I have a .envrc
that looks like this,
export KUBECONFIG ="$(expand_path ./kubeconfig)"
this way every time I cd
into that project it auto switch context.
Direnv is a great solution for this! I'm gonna close this issue for now. Let me know if you have other ideas for the project!
It's technically more that a kubeconfig would be tied to a session. In my case, I prefer a separate tmux session for each kubeconfig. I could use the direnv solution, but my kubeconfigs aren't tied a a particular project so its pretty much the same as I what I do now with separate configs. Therefore what I have now works - was mostly providing some ideas that were running through my head :). Thanks for listening and building sesh!
What would you like sesh to do?
I've started using sesh in particular with its integration with zoxide and tmux which works great and helps with context switching on the CLI.
I switch kubernetes contexts very often. While there are many tools to do this, they only set the current context for the CLI session that you are on. Things get ugly when I have multiple panes or windows with different contexts set, so having them in separate tmux sessions is much more efficient. Therefore, I wanted to have the same context switching that sesh provides in tmux, but for kubectl contexts.
My solution to this for the time being is to add a several sessions to the sesh config with a startup command to set the
KUBECONFIG
environment variable. However, I think it would be awesome to have sesh support these out of the box like it does with zoxide. This would require parsing the yaml files under.kube
and grabbing the contexts from there, similarly to how tools like kubectx does.While this is just one feature, it also made me think that it might be cool to have sesh support custom lists (perhaps in the config file). As an example, one could create a custom command to provide a list of strings, so that when you run
sesh list
, it would show the resulting list of strings there. From that you can have a similar key for a startup command to run for that custom list. An example of this could look like: