Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for tmuxinator start --append #652

Closed
wants to merge 0 commits into from

Conversation

flovilmart
Copy link

Closes: #265

@ethagnawl
Copy link
Member

Thanks for this, @flovilmart! I'll try to give it a proper review before the end of the week.

@flovilmart
Copy link
Author

Take your time @ethagnawl! No rush for that, i'm using it at the moment and probably will weed out some odd edge cases. Also, if you need I can try to add some tests. I'm not very used to ruby though, so it could take time.

@DestyNova
Copy link

Very nice. The only confusing bit is that it names the new window <session-name>:<window-name> -- i.e. if I append a window called muffin from a file containing the line name: mountain, then the new window will be called mountain:muffin. If I don't specify the name parameter in the Yaml file, then the window will be called :muffin.

I see there is some logic to control this behaviour, but I don't fully understand it. Is there an extra flag or configuration value needed to just have the window be called muffin?

@flovilmart
Copy link
Author

@DestyNova that would be a possible change, if the name is not set with the tmux template I could probably remove the separator. This was intended to make it easy to see which windows were appended.

@DestyNova
Copy link

Yes I see the motivation for it and it makes sense -- in my case though, I expect to end up with a bunch of files that each describe one window with a couple of panes. Since I use windows and panes where other people might use sessions and windows, I don't need that namespacing. Maybe the behaviour could be specified with an optional flag (e.g. if a simple name is default, then add -p for prefix-with-session-name, or if the namespaced window name is default, then -s for simple-window-name or something)?

@flovilmart
Copy link
Author

I’m not sure I want to spend additional time adding more configuration flags to this PR. If the naming of the windows is problematic i’ll Remove it altogether and restore the original behavior instead of prefixing with the screen name.

@DestyNova
Copy link

I like the PR either way and am really happy someone has finally done this. Rather than sidetrack the PR, I'll try to do a separate one adding such a flag afterwards. Thanks for doing this :)

@ethagnawl
Copy link
Member

@flovilmart This is looking pretty good!

I do have a few questions/thoughts/requests/etc. for you:

1.) Would you mind adding an entry to the "Other Commands" section of README.md in your PR which documents how this feature and its various CLI options are intended to be used?

The documentation will be useful for users going forward and for people reviewing this PR. I wasn't following #265 closely and it took me a few minutes to figure out how this feature was intended to work.

2.) A missing/malformed current_session: ... seems to result in tmuxinator wantonly appending windows to whatever the most recently created tmux session is, which seems undesirable. Is this by design? Is there a way you can sniff out whether or not the current_session exists and either fail or start a new session if it doesn't? (I'll revisit the code myself, but I'm on my way out for the day.)

3.) Could you replace puts with say in Cli.rb?

4.) Perhaps the "Creating new session ..." message should contain the session name?

5.) We will need some tests around this new behavior. Did you ever get a chance to take a pass at writing any? I know you said you're not used to Ruby, so I can appreciate how that might be a bit daunting and it's awesome that you were able to put this together. (I don't think you're giving yourself enough credit!) If not, that's totally fine and I can take a pass at writing some and submit another PR to your branch.

@flovilmart
Copy link
Author

All of those make sense, i’ll Have a look at the requests and will do the tests as well.

I’m only an amateur rubyist, punching letters in to get the expected result as such as often fail to recognize idiomatic patterns. Therefore the code I produce is most likely to be linearly dumb :)
Yet those are no excuses for not trying :)

@flovilmart
Copy link
Author

I Didn’t forget about this one, but my todo list keeps pushing it down. I hope to have more time soon

@raiyuza
Copy link
Contributor

raiyuza commented Feb 8, 2019

@flovilmart Any ETA, we in 2019 already :)

@flovilmart
Copy link
Author

Well, yea, I need to but my head back into it :)

Sent with GitHawk

@icole
Copy link

icole commented Apr 5, 2019

Any issue with getting this merged now that the merge conflicts are resolved?

@flovilmart
Copy link
Author

@icole I need to work on the few tests and documentation. I haven't found a good time to do it. I'll try this weekend.

@icole
Copy link

icole commented Apr 5, 2019

@flovilmart awesome, thanks for the response. If you could use any help with anything let me know. Would love to see this go out.

@flovilmart
Copy link
Author

Thanks @icole I'll do my best to address all the concerns and add the relevant tests. I'd love to get done with this one. Sorry to have dropped the ball.

@flovilmart flovilmart changed the title Adds support for tmuxinator append Adds support for tmuxinator start --append Jun 25, 2019
@flovilmart
Copy link
Author

@icole Sorry for the late response. I changed a bit the logic so it uses mux start --append [project] instead of mux append. This simplifies a bit the logic.

I'll add some tests around the in_current_session logic to make sure this is readable easily and maintainable as well.

@icole
Copy link

icole commented Jun 28, 2019

@flovilmart thanks so much! could we pull this in after you add those tests? I am dying to get this in since the version this is based off is older than what our projects Gemfile requires.

@betoharres
Copy link

I was trying to figure out if tmuxinator had this feature; well, hope it gets merged!

@flovilmart
Copy link
Author

I completely forgot I had this one open, thanks for the ping 😅! I’ll do my best.

@protex
Copy link

protex commented Jul 22, 2020

Any chance this gets merged? It would be super useful.

@flovilmart
Copy link
Author

@icole what what left for update? I wanna go ahead with this. Can you pin point in the code the different changes required for the merge?

@ethagnawl
Copy link
Member

From what I recall, it's a minor Code Climate nitpick. Unfortunately, the build is old enough that it's been dropped by CC. Could you try pushing a new commit in order to trigger a new build, @flovilmart?

@flovilmart
Copy link
Author

flovilmart commented Aug 13, 2020

@ethagnawl the problem is that the start method now is too complex, not sure how to simplify it given it's already quite simple. Any suggestion?

@ethagnawl
Copy link
Member

I haven't used Code Climate in a long time and don't remember how some of their metrics work. I'd say maybe removing the project variable and nesting those method calls would work, but the more likely/correct solutions would be extracting those conditionals or moving the has creation into its own method.

Does anyone else have any thoughts about this or the PR in general? CC/ @tmuxinator/tmuxinator

@flovilmart
Copy link
Author

@ethagnawl , finally, codeclimate passed! 🎉

@ethagnawl
Copy link
Member

Okay, that's great. I'll have to find some time to review this again.

Sorry for the bother, but does anyone else have any thoughts? /CC @tmuxinator/tmuxinator

@flovilmart
Copy link
Author

thanks @ethagnawl !

@@ -25,6 +25,10 @@ def home?
File.directory?(home)
end

def options_file
directory + ".yml"
Copy link
Member

@ethagnawl ethagnawl Sep 22, 2020

Choose a reason for hiding this comment

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

The "yaml" extension is also supported. I tried using a project config file with this extension and everything worked as expected. Does that imply that this method isn't being used or am I overlooking something?

EDIT: After reading through this again, I don't think this could ever work. (Again, I may be missing something.)

Copy link
Author

Choose a reason for hiding this comment

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

what do you suggest?

Copy link
Member

Choose a reason for hiding this comment

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

Either this method needs to support both extensions or, if I'm correct in that it's not being used, it should be removed.

base = 0
if in_current_session
# Get the last window index + 1
base = 1 + `tmux list-windows | awk '{print $1}'`.split.last.to_i
Copy link
Member

Choose a reason for hiding this comment

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

I think this awk logic should either be handled in Ruby code or we should add a method to the Doctor class which verifies that awk exists on the user's system.

Copy link
Author

Choose a reason for hiding this comment

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

fair, let's me see what I can do


def should_append?(options)
options[:append] == true ||
(options[:append] != false && Tmuxinator::Config.options[:append])
Copy link
Member

@ethagnawl ethagnawl Sep 22, 2020

Choose a reason for hiding this comment

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

Could you walk me through the use case for the right side of this || and the related Config method?

Copy link
Author

Choose a reason for hiding this comment

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

the idea is that can set append in the Tmuxinator::Config.options so all sessions are appending by default.
if append is not provided by the options (case != false) we check that it is set in the global Config.

@kurktchiev
Copy link

any chance we can get this merged any time soon? it would really boost productivity with tmux/tmuxinator

@cibinmathew
Copy link

@ethagnawl @flovilmart @icole Thanks for this work.
Can we get this merged or may be list down the blocking issues and open another to track the enhancements. We could pitch in to get this to a closure.

@ethagnawl
Copy link
Member

@ethagnawl @flovilmart @icole Thanks for this work.
Can we get this merged or may be list down the blocking issues and open another to track the enhancements. We could pitch in to get this to a closure.

There are still some issues (noted above) which need to be worked through. (If you feel like running with what's been done and @flovilmart doesn't mind, feel free to pick them up.) It'd also be good to get feedback from others in @tmuxinator/tmuxinator.

@flovilmart
Copy link
Author

@ethagnawl let me get back on it

Copy link

@noahfrederick noahfrederick left a comment

Choose a reason for hiding this comment

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

Looking forward to this feature. I left a drive-by review of the code changes.

lib/tmuxinator/config.rb Outdated Show resolved Hide resolved
lib/tmuxinator/cli.rb Outdated Show resolved Hide resolved
lib/tmuxinator/project.rb Outdated Show resolved Hide resolved
Comment on lines 111 to 112
project_name = project.in_current_session ? "#{project.full_name}:" : ""
name ? "-n #{project_name}#{name}" : ""

Choose a reason for hiding this comment

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

I would prefer to drop this change, i.e., for the window to always be named without the prefix.

@flovilmart
Copy link
Author

Thanks @noahfrederick will have a look later

@@ -56,6 +60,12 @@ def default
"#{directory}/default.yml"
end

def options
YAML.safe_load(File.read(options_file), [], [], true) || {}
Copy link
Member

@ethagnawl ethagnawl Jun 8, 2021

Choose a reason for hiding this comment

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

@flovilmart Would you mind using the new safe_load method signature (remove positional parameters two, three and four and provide keyword argument for aliases)? As-is, this will cause errors in some environments because of changes to Psych and libyaml.

It would look something like this:

YAML.safe_load(File.read(options_file), aliases: true)

See this PR for more context.

@megalithic
Copy link

@flovilmart / @ethagnawl -- just pinging those that have worked on this. How are we feeling about your concerns being addressed and getting this merged?

@flovilmart
Copy link
Author

@megalithic I haven't had the chance to actually finish this one; yeah I know, that's kinda pathetic after all this time 🤣

@ethagnawl
Copy link
Member

@flovilmart I know your comment was in jest, but it's not pathetic at all. Your contributions are being provided at the expense of whatever else you might be doing with your life and are greatly appreciated.

@megalithic
Copy link

@ethagnawl @flovilmart 💯 agreed! OSS is a gift! i'm grateful for each of you that contribute/create such amazing tools.

@flovilmart
Copy link
Author

Haha! Thanks y’all! very appreciated. I need to find some time for this. I see this is pretty requested.

@ChrisYin
Copy link

I'm wondering when this patch can be merged? Looks like it has a long history from 2018.

@martin-braun
Copy link

@flovilmart I know this issue probably hunts you in your dreams already, is there still any chance that you find the time to finish this?

@akofink
Copy link
Contributor

akofink commented Mar 31, 2024

I attempted to rebase this with tmuxinator:master, but I accidentally pushed the latest master, which auto-closed the PR. I have an updated branch that I will use to re-open a new PR, since I can no longer push to this original branch. Apologies!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Option to create window in the same tmux session instead of creating a new session