Skip to content

Conversation

@PiquelChips
Copy link
Contributor

@PiquelChips PiquelChips commented Mar 11, 2025

Changes

  • Makefile: changed to go env GOPATH in case you don't have GOPATH in your env.
  • Model:
    • Added WindowConfig type to be loaded from toml file.
    • Added list of window names to SessionConfig that will be matched to WindowConfig struct later on.
    • Added array of window configurations to SeshSession to be used when starting the session.
  • Tmux:
    • Added NewWindow function.
    • Added NextWindow function to be used to go to last window of session when session is started with multiple windows.
    • Regenerated mockery files.
  • Lister:
    • Check that windows are configured properly.
    • Make map of windows to be able to match them with the sessions.
    • When setting up sessions: loop over provided window names and match to the ones in the map. Use session path if not specified.
    • Return sessions with the window configuration structs instead of strings.
  • Connector:
    • Loop over window configurations of the session and open each one with the startup command (if needed).
    • Go to next window as current should be last one, this will send to first window.
  • Update README with new configuration options.

Result

You can now define windows in the configuration file. There are four different configuration options. If path is omitted, the session's path will be used.

[[window]]
name = "git"
path = "~/git"
startup_script = "git pull"
disable_startup_script = false

Then, you can populate the windows array in session configurations with the names of the windows that the session will use.

[[session]]
name = "tmux config"
path = "~/c/dotfiles/.config/tmux"
startup_command = "nvim tmux.conf"
preview_command = "bat --color=always ~/c/dotfiles/.config/tmux/tmux.conf"
windows = [ "git" ]

@PiquelChips PiquelChips marked this pull request as draft March 11, 2025 16:35
@PiquelChips PiquelChips changed the title Makefile: Used go env command to get output location Session.window in sesh.toml Mar 11, 2025
@joshmedeski
Copy link
Owner

go env GOPATH is better for consistency with the system, especially in the context of Go development. It ensures that you get the ⁠GOPATH as understood by the Go toolchain, including any defaults or configurations applied by Go itself, rather than relying solely on the shell environment settings.

Any reason specifically you change this?

@joshmedeski
Copy link
Owner

Is this going to be for #201?

@PiquelChips
Copy link
Contributor Author

PiquelChips commented Mar 11, 2025

Yes. I changed to go env go path mainly for myself as the GOPATH bar is not in my environment and I thought other people might have a similar problem. However, adding the variable to my env would not be an issue so I can undo this if you want.

@PiquelChips PiquelChips changed the title Session.window in sesh.toml Multiple windows for session configuration in sesh.toml Mar 13, 2025
@PiquelChips PiquelChips marked this pull request as ready for review March 13, 2025 17:15
@joshmedeski
Copy link
Owner

Thanks, I'll look this over and provide feedback this week.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces multi-window support for session configuration through the sesh.toml file by adding new commands and configuration options.

  • Added NewWindow and NextWindow functions in the tmux package and their associated mock methods.
  • Extended session and configuration models to support a list of window configurations.
  • Updated the session listing and connector logic to leverage the new window definitions.

Reviewed Changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tmux/tmux.go Added NewWindow and NextWindow functions to initiate new windows.
tmux/mock_Tmux.go Added mocks for the new tmux window functions.
model/sesh_session.go Extended session model to include window configurations.
model/config.go Defined WindowConfig and added windows array to configuration models.
lister/config.go Updated configuration parsing to map and assign window settings.
connector/tmux.go Implemented multi-window startup in session connector.
README.md Updated documentation to cover the new multi-window configuration.
Files not reviewed (1)
  • Makefile: Language not supported

Copy link
Owner

@joshmedeski joshmedeski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it's a solid idea and simple interface. I'm still hesitant to integrate complicated tooling like this, because so many other existing tools already exist list tmuxinator, or even just simple bash scripts, that make it more flexible without sesh having to deal with the overhead of bugs and additional feature requests (like panes).

What do you think? Have you tried other tmux project scaffolding tools and how do you think it compares to this?

Thanks again for putting in the work, it's a great start and if we agree that this is a good idea to expand on then I'm happy to continue through the code review process and get this merged soon.

@PiquelChips
Copy link
Contributor Author

I used to use tmuxifier which worked with shell scripts, however I recently moved to NixOS and tmuxifier is not in nixpkgs. For some reason, I never came across tmuxinator and found this as well. As I really liked the multi-window feature in tmuxifier I tried to reproduce it here.
Once again, I don't know how I missed tmuxinator and I understand why you are reluctant to integrate these changes. If you wish to keep sesh as simple as possible I understand that these changes do add complexity and will just use my fork of the repo (or switch to something like tmuxinator). However, if you think these are relevant enough, I would be happy to help merging these changes.
So in my opinion, it depends on the scope you are going for with this project. If you want it to reach the complexity of tmuxinator, this feature will help. However, if you want this to be a light weight tool for simple things then I agree the changes are a bit too much.

Copy link
Owner

@joshmedeski joshmedeski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After examining the window logic I'm realizing now there is a better place for it, once you move it I'll do some final testing and merge!

Overall, I really like how composable this approach is and I could see myself using it for my own workflow 😁

@joshmedeski joshmedeski self-requested a review April 18, 2025 15:55
Copy link
Owner

@joshmedeski joshmedeski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this work!

@joshmedeski joshmedeski merged commit 6e43f37 into joshmedeski:main May 28, 2025
4 checks passed
@nickrschnelle
Copy link

Would it be possible to get a new release with this functionality included? Redoing my dev setup and would love to make use of it

@joshmedeski
Copy link
Owner

Yes, I was waiting for one more feature to be complete. But I may just move forward with a release!

@jakmaz
Copy link

jakmaz commented Jun 25, 2025

Hey, that's a really nice feature that I've been waiting for.
Unfortunately I have some troubles setting it up. I basically want to always open two tmux windows for me, one with neovim, and second an empty one. I cannot get it to work though. with this being my current configuration. Am I doing it right?

[default_session]
windows = [ "nvim", "terminal" ]

[[window]]
name = "nvim"
startup_script = "nvim"
disable_startup_script = false

[[window]]
name = "terminal"

Before, I just used an sh script that I run on every default session. Also, I don't know if that's the right place to ask, I can move it to discussions if needed!

@joshmedeski
Copy link
Owner

@jakmaz I think startup_script is required on the window in order for it to work. I recommend using ls or something simple just to get it to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants