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

Re-use the vimux pane over sessions #70

Closed
yfyf opened this issue Jun 15, 2013 · 8 comments
Closed

Re-use the vimux pane over sessions #70

yfyf opened this issue Jun 15, 2013 · 8 comments

Comments

@yfyf
Copy link

yfyf commented Jun 15, 2013

Hi,

First of all, pretty awesome plugin, good integration with a proper shell is something I've always been jealous of Emacs users and this is at least some steps in that direction.

What I'm missing though is the ability to do this:

  1. Start vim
  2. Send some commands via vimux and obtain a new vimux pane
  3. Close vim, leave the vimux pane open
  4. Do some stuff, start vim again
  5. Run more commands via vimux, but instead of vimux creating a new pane, it re-uses the old one.

This would allow to have a kind of "dedicated" tmux pane which acts as REPL. This could be a configurable option such as VimuxUniquePane.

The only problem is that it's kind of hard to access pane's in tmux, but there are two hackish approaches:

  1. Set the pane title to something like VimuxPane and add a check to look if one exists next time vimux is used. Note that the pane title is not set or maintained by tmux, it's the title set by the OSC title setting sequence, so potentially it can be changed by something running in the shell, which is not nice.
  2. Store the vimux pane ID (not index) (which is unique over the whole session according to tmux's docs) somewhere and reuse that.

I think the second approach is much less hackish, but then the pane ID needs to be stored somewhere.
EDIT: I guess viminfo could be used for that? :help viminfo

If you would agree with such a feature I could contribute a patch for this.

@benmills
Copy link
Collaborator

I think what you're taking about is g:VimuxUseNearestPane which is a setting which is turned off by default. Check out the vimux docs for more specifics. In the mean time I'm going to close this issue, if you feel there is still a use case comment again and I'll reopen.

@yfyf
Copy link
Author

yfyf commented Jun 16, 2013

Nope, g:VimuxUseNearestPane is not it, it doesn't preserve the pane that was used initially. For example if I start vim, use vimux (and hence create a new pane), then create a new pane manually, close vim and start vim again it will now use the latest pane created, which is not what I want. I want it to always use the same pane.

@yfyf
Copy link
Author

yfyf commented Jun 16, 2013

Obviously it would make these two options kind of mutually exclusive.

@benmills benmills reopened this Jun 16, 2013
@yfyf
Copy link
Author

yfyf commented Jun 20, 2013

Bump. What's your opinion on this?

@benmills
Copy link
Collaborator

I understand what you're looking for, but I'm worried that it's adding too much complexity to vimux. Just to make sure I'm clear, you want to persist the global vim variable that holds the pane id so that it is the same between vim restarts?

This is how I think I would do this without adding it to vimux: If you check out where I actually target the pane to send the text to it here I use the global variable g:VimuxRunnerPaneIndex. You could add this to your vimrc:

let g:VimuxRunnerPaneIndex = readfile("/tmp/vimux_runner_pane_index")[0]

This is obviously pretty brittle and you could harden it a bit by checking to make sure the contents of the tmp file is an integer and that it is a tmux pane that exists in the current window. (You might be able to just use this function that I use internally _VimuxHasPane[1]

[1] https://github.com/benmills/vimux/blob/master/plugin/vimux.vim#L145

@yfyf
Copy link
Author

yfyf commented Jun 21, 2013

Thanks for coming to this.

On 06/21/2013 12:55 AM, Ben Mills wrote:

I understand what you're looking for, but I'm worried that it's
adding too much complexity to vimux. Just to make sure I'm clear, you
want to persist the global vim variable that holds the pane id so
that it is the same between vim restarts?

Well, almost, pane_id per tmux-window/session.

This is how I think I would do this without adding it to vimux: If
you check out where I actually target the pane to send the text to it
here
https://github.com/benmills/vimux/blob/master/plugin/vimux.vim#L50
I use the global variable |g:VimuxRunnerPaneIndex|. You could add
this to your vimrc:

let g:VimuxRunnerPaneIndex =
readfile("/tmp/vimux_runner_pane_index")[0]

This would not quite work as it would only make sense if you ever have
one window open, I want to have a unique pane per-session, not totally
globally. Also, pane_index is the wrong thing to refer to, see the
comment bellow. I wouldn't fancy using files explicitly and a hardcoded
path to /tmp/ too. As I've mentioned, viminfo could be used to store
some state.

This is obviously pretty brittle and you could harden it a bit by
checking to make sure the contents of the tmp file is an integer and
that it is a tmux pane that exists in the current window. (You might
be able to just use this function that I use internally
|_VimuxHasPane|[1]

Well, this is exactly what is wrong: you need to look at pane_id not,
pane_index, see the tmux manual.

pane_id is unique for the whole session, pane_index changes when you
destroy a pane for all panes whose indexes are higher that that of the
destroyed pane.

Anyway, I don't think this is that complex. I'll try to implement this
and send a PR at some point, then you can make a judgement whether it's
complex or not.

@alerque
Copy link
Member

alerque commented Feb 14, 2021

Might this issue be addressed by the upcoming contribution in #138?

@m42e
Copy link
Contributor

m42e commented Feb 14, 2021

Closed by #180

@m42e m42e closed this as completed Feb 14, 2021
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

No branches or pull requests

4 participants