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

Add the ability to append windows to a session #656

Merged

Conversation

will-ockmore
Copy link
Contributor

Based off of the work already submitted in #501. Unfortunately I wasn't able to rebase the commits cleanly as it was too far diverged from master. All credit for the idea and structure should go to @emanuelhfarias 👏

All I've added is a bit of code cleanup, and a bugfix regarding the behaviour of appending windows to a session when there is more than one attached.

Quoted below is the original PR description:

I see some people requesting this feature (me included) #289 #373 and some even tried to add this functionality #374 #407 but those ideas never went from draft.

I decided to implement this feature maintaining the compatibility with features we already have (open attached and detached). The motivation to this feature is because I feel more productive seen everything I have opened as visible windows. I tried to use several sessions and switch-sessions using tmux shortcut C-b s but I didn't get use to it (maybe I will try again in the future).

Summarizing what this PR adds:
When you try to load a config file within a current open tmux session it will ask you if you want to:

create a new session and attach?
create a new session and detach?
load config appending windows in the current active session?

To maintain the compatibility I didn't change the question, I just added another option to the user.

Already inside TMUX, switch to session? yes/no
Or (a)ppend windows in the current active session?
[y/n/a]:

If you anwser:
Yes it will attach
No will detach
Append will append windows in the same session

I also added the ability to force append using the CLI:
$ tmuxp load -a config

My motivation is much the same - I like to use sessions to organise different groups of projects, and within those each project will use one or more windows. I find switching between windows more intuitive and prefer the extra organisation choices this method gives me!

Modifies the behaviour when starting a session from within an existing
tmux session: the user is given the choice to switch to new session, do
nothing, or append to current session.
@codecov
Copy link

codecov bot commented Jan 5, 2021

Codecov Report

Merging #656 (0660049) into master (77c0cb6) will decrease coverage by 0.24%.
The diff coverage is 61.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #656      +/-   ##
==========================================
- Coverage   76.18%   75.93%   -0.25%     
==========================================
  Files           8        8              
  Lines        1142     1180      +38     
  Branches      286      295       +9     
==========================================
+ Hits          870      896      +26     
- Misses        196      204       +8     
- Partials       76       80       +4     
Impacted Files Coverage Δ
tmuxp/cli.py 73.73% <52.83%> (-0.21%) ⬇️
tmuxp/workspacebuilder.py 87.84% <84.21%> (-1.24%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 77c0cb6...0660049. Read the comment docs.

@will-ockmore
Copy link
Contributor Author

@tony this PR is hopefully what you were asking for in this comment - let me know if any further changes are needed 👍

@tony tony self-requested a review January 6, 2021 13:56
All of these options can be preselected to skip the prompt:

.. code-block:: bash
$ tmuxp load -y config # load attached
Copy link
Member

Choose a reason for hiding this comment

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

In tmux lore, typically -a is reserved for attaching.

Is there any other posix / unix-like apps that have another arg they use to mean append? (Not a requirement of course)

Copy link
Member

Choose a reason for hiding this comment

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

I'm looking through this PR as a whole, and -a / (a)ppend seems to make the most sense and "fit" the best to me. Nice

Copy link
Member

@tony tony left a comment

Choose a reason for hiding this comment

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

Impressive! Works very well.

Let's keep the __version__ as-is for now (0660049). This way when 1.7.0 is final / gold, appending will be there with our plugin system.

Go ahead and merge when you're ready.

(I will aim to release this as part of 1.7.0 this weekend)

@will-ockmore
Copy link
Contributor Author

Great! I don't have permission to merge so if anyone does, go for it. Thanks for the quick approval!

@tony
Copy link
Member

tony commented Jan 7, 2021

Great! I don't have permission to merge so if anyone does, go for it. Thanks for the quick approval!

Check your email for an invite.

@will-ockmore
Copy link
Contributor Author

will-ockmore commented Jan 7, 2021

Nothing in my inbox, and I can't join via the direct link (as described here) - would you be able to resend the invite?

@tony
Copy link
Member

tony commented Jan 7, 2021

@will-ockmore Resent

It's an email from GitHub, so you need to check the email on your account

Maybe you'll see invites in the org itself? https://github.com/tmux-python/

https://github.com/orgs/tmux-python/invitation

Let me know if it's any better, if that doesn't work, email me! (my email is on my profile)

@tony
Copy link
Member

tony commented Jan 7, 2021

p.s.

@will-ockmore Also be sure you're checking your personal GH account and not an alternate / work one, if there is one

@will-ockmore
Copy link
Contributor Author

Got the org invite, thanks! No idea why the repo invite didn't work 🤷‍♂️

@will-ockmore will-ockmore merged commit 2a197c9 into tmux-python:master Jan 8, 2021
@will-ockmore will-ockmore deleted the append-window-same-session branch January 8, 2021 13:19
@tony
Copy link
Member

tony commented Jan 9, 2021

@will-ockmore This is live

https://pypi.org/project/tmuxp/1.7.0/

https://tmuxp.git-pull.com/history.html#tmuxp-1-7-0-2021-01-09

How's it workin? (If there's any quirks we can iron them out in patch releases, if not, that's good too. In either event, job well done!)

@will-ockmore
Copy link
Contributor Author

Installed and been using it today - seems to be working great. Thanks for cutting the release, let me know if there are any problems you find - will keep an eye out over the next week and see if I can find any bugs!

@tony
Copy link
Member

tony commented Jan 10, 2021

@will-ockmore Awesome! Excited to have this and @joseph-flinn's Plugin system and debugging updates live!

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.

None yet

2 participants