-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
Allow tmux session name to be passed as env var #1703
base: master
Are you sure you want to change the base?
Conversation
👍 on the general idea here. I had a hard time stepping through the code... have you tested all these scenarios? Also, your PR has a great explanation... maybe copy some of that to the |
Yes I've tested all the scenarios mentioned. I've been using this since 2015 and use all four scenarios on a daily basis. I had to re-code the logic a little bit to keep up with prezto changes, but the basic idea is the same. The code isn't that complicated to step through:
I'm on the road right now but will try to add docs at some point. |
nudge re: adding docs as previously discussed |
For normal usage this change should be a NOOP. However it enables the use case where the user might want to predefine what session gets connected to when the shell is launched. Running `zsh` will still net you a connection to the last used tmux session or a new one named "zprezto" if none exists. However `env tmux_session=myname zsh` will connect you specifically to a session called 'myname' including creating it if it doesn't exist. This is particularly useful in window managers where a key binding might open a terminal with a predefined session or even show a list of current sessions and open a new terminal connected to that session. The default session name may still be set using zstyle as documented.
d3462b1
to
c3f1794
Compare
Thanks @jeffwidman, you caught me at a computer this time (since the issues isn't assigned to me it wasn't really staying on my radar!). I've added some documentation to the README and stuffed it in the same commit. |
Thank you! So stepping through this, I'm a little confused. You said:
However, reading the code and the comments, it looks like the fallback behavior does change from the last session session used to instead using the "prezto" session name. If someone doesn't set this var, and last used a different session name, will this change the behavior for them to instead start attaching to the "prezto" name? I don't have an opinion yet whether that is a good or bad thing--it might be an improvement it might not, but I first want to make sure I understand how this works. |
@jeffwidman Thanks for your patience. My logic did in fact slip a cog somewhere, this needs to be a 4 stage fallback not a 3 stage fallback.
Да? |
Note this is a replacement for the obsolete PR #952.
I finally got this actually figured out and rebased on master. The priority is now:
For normal usage this change should be a NOOP. However it enables the
use case where the user might want to predefine what session gets
connected to when the shell is launched. Running
zsh
will still netyou a connection to the last used tmux session or a new one named
"zprezto" if none exists. However
env tmux_session=myname zsh
willconnect you specifically to a session called 'myname' including creating
it if it doesn't exist.
This is particularly useful in window managers where a key binding might
open a terminal with a predefined session or even show a list of current
sessions and open a new terminal connected to that session.
The default session name may still be set using zstyle as documented.