prezto icon indicating copy to clipboard operation
prezto copied to clipboard

make tmux module have optional attach behavior

Open milkypostman opened this issue 10 years ago • 19 comments

This commit reverts the tmux module back to the original behavior but doesn't set destroy-unattached to on on globally and provides an option for attaching to the background or last-used session.

milkypostman avatar Mar 26 '14 15:03 milkypostman

I haven't tried this yet but from the description it souds as it would allow for the different use cases as discussed in #581.

What I like especially is the zstyle for a default session. I was suggesting that earlier somewhere but as @sorin-ionescu isn't too keen on adding more zstyles I made do with it. But maybe now that a situation arose that is becoming more and more complex it might be ok to add zstyles to provide for this?

nasenatmer avatar Mar 26 '14 16:03 nasenatmer

Looks good to me. Will try it by tomorrow morning.

xcambar avatar Mar 26 '14 16:03 xcambar

i'm not sure having a default session name is correct here. i think that we should probably try to search for the existing session if one exists for which we can attach, and final case we create a new one. i will work on an update.

milkypostman avatar Mar 26 '14 22:03 milkypostman

Tried it. Couldn't have it to work, with or without setting the options. Don't have time to figure out why yet, but basically, no more zprezto for me (not only tmux, but git, prompt and other plugins too)

Here's the configuration I've used

# Auto start a session when Zsh is launched in a local terminal.
zstyle ':prezto:module:tmux:auto-start' local 'yes'

# Auto start a session when Zsh is launched in a SSH connection.
# zstyle ':prezto:module:tmux:auto-start' remote 'yes'
zstyle ':prezto:module:tmux:auto-start' mode 'attach'
# zstyle ':prezto:module:tmux:auto-start' mode attach  #tried without the quotes too, as per the docs
zstyle ':prezto:module:tmux:auto-start' session 'sweet'

I plan to try to figure out why before tomorrow, if you haven't already by that time.

Cheers!

xcambar avatar Mar 27 '14 08:03 xcambar

I updated and cleaned up a bit. let me know how tis works for you and see if it is less complicated or confusing.

any advice on how to make it a bit less confusing would be helpful.

milkypostman avatar Apr 19 '14 05:04 milkypostman

Mode shared works for me.

Side note: I don't mean to discuss the usefulness of the "not shared" mode (I don't, please), but I spent 10-15min playing around with it trying to figure out how I could use it, and I ended up concluding it is way beyond my comprehension. I almost felt stupid :smile:

xcambar avatar Apr 25 '14 19:04 xcambar

Do you mean the original way? Because "not shared" should be the same as the old default. I will make a screencast showing how I use it.

On Friday, April 25, 2014 12:49:42 PM, Xavier Cambar < [email protected]> wrote:

Mode shared works for me.

Side note: I don't mean to discuss the usefulness of the "not shared" mode (I don't, please), but I spent 10-15min playing around with it trying to figure out how I could use it, and I ended up concluding it is way beyond my comprehension. I almost felt stupid [image: :smile:]

— Reply to this email directly or view it on GitHubhttps://github.com/sorin-ionescu/prezto/pull/582#issuecomment-41432550 .

milkypostman avatar Apr 25 '14 20:04 milkypostman

ping @sorin-ionescu

milkypostman avatar May 18 '14 05:05 milkypostman

I have not forgotten.

sorin-ionescu avatar May 18 '14 15:05 sorin-ionescu

@xcambar I made a video demonstrating the awesomeness of the original implementation.

http://youtu.be/LRP-moHvT04

milkypostman avatar May 18 '14 20:05 milkypostman

What do you do at 0:48 when you „create another window/connection” and you access the same session from the left and the right screen? Is that a function of your terminal programme? I guess this is where the use cases of you and (most) others differ: It seems you're using your terminal emulator for that while it is exactly the purpose of tmux to do this.

nasenatmer avatar May 18 '14 21:05 nasenatmer

@nasenatmer that was only for the demo. I use dual displays at work and I have multiple desktops. I sometimes want to open a new terminal on another desktop or screen and have it view something different from what is being viewed on the other screen/desktop. yes, tmux can do something similar with splits but it is not as powerful in that "tmux panes" do not exist in the top level window system.

milkypostman avatar May 18 '14 22:05 milkypostman

also, i have never found "panes" in tmux to be anything but a pain (pun intended). it is not easy to change the contents of one pane inside a window to a different pane in a different window. That is, once you have set the contents of a tmux pane, it cannot change.

milkypostman avatar May 18 '14 22:05 milkypostman

Thanks for the video @milkypostman, very useful! It should be kept as a reference for newcomers.

Still one question: What if I change the active session in a tab? Will it switch on all tabs?

Nota: Use the commands new-session -s SESSION_NAME and choose-tree to play with sessions.

xcambar avatar May 23 '14 12:05 xcambar

i am assuming you're saying "tab" to represent each terminal window. i don't believe that it should change on all tabs. i mean, i don't think that is true with either approach.

On Fri, May 23, 2014 at 5:49 AM, Xavier Cambar [email protected]:

Thanks for the video @milkypostman https://github.com/milkypostman, very useful! It should be kept as a reference for newcomers.

Still one question: What if I change the active session in a tab? Will it switch on all tabs?

Nota: Use the commands new-session -s SESSION_NAME and choose-tree to play with sessions.

— Reply to this email directly or view it on GitHubhttps://github.com/sorin-ionescu/prezto/pull/582#issuecomment-44004662 .

milkypostman avatar May 23 '14 15:05 milkypostman

This looks really interesting, I've found it really frustrating to effectively be limited to 1 terminal by the behavior of the tmux plugin.

One thing I didn't see in your video, how does this act when windows are different sizes? Does tmux limit everything to the size of the smallest frame (this is the current behavior)?

sirreal avatar Oct 03 '14 11:10 sirreal

@sirreal That is a tmux setting. I think it's aggressive-resize. It basically means that whatever window is being looked at will be the resized one, but not all.

so if you're on window 1 at 10x10 and window 2 at 20x20 then they will both be those sizes. However, if both are looking at window 2 then it will be 10x10 on both.

milkypostman avatar Oct 04 '14 01:10 milkypostman

Why this was not merged? Seems pretty nice and fix that #1485

ryukinix avatar Oct 13 '17 04:10 ryukinix

Another thing I dislike with the tmux module is the exec part, this make it impossible to simply detach but not close the terminal if I want to. The exec part (leave zsh on detach) could be optional. It has been 4+ years, sadly it seems no one is looking into this anymore...

oblitum avatar Dec 12 '18 01:12 oblitum