save/restore tmux windows

Bug #907363 reported by Dustin Kirkland 
120
This bug affects 22 people
Affects Status Importance Assigned to Milestone
byobu
Fix Released
Medium
Unassigned

Bug Description

Is it possible to define windows to be created at startup when using tmux?

When uising screen the startup windows can be defined using $BYOBU_CONFIG_DIR/windows but that does not seem to work with tmux.

Changed in byobu:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Not yet, but should be soon.

You'd use ~/.byobu/windows.tmux

Revision history for this message
Dustin Kirkland  (kirkland) wrote :
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Attaching non-working patch here. I'll come back to this one day.

Changed in byobu:
status: Triaged → Confirmed
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

Note to self: we now have a first-run procedure within byobu-status. This would be the place to launch saved windows. I'll get to this soon.

Changed in byobu:
status: Confirmed → Triaged
Revision history for this message
Björn Torkelsson (torkel) wrote :

Would it be possible to also set window-names in first-run?

Revision history for this message
Dustin Kirkland  (kirkland) wrote : Re: [Bug 907363] Re: save/restore tmux windows

What do you mean, Bjorn? What would you set them to? The answer, I
think, is an easy "yes", but I need to understand it a bit better.

Revision history for this message
Björn Torkelsson (torkel) wrote :

My "default" setup is that as soon as I start byobu I create three windows. The first one runs top, in the second one I run sudo -i, and in the third one an ordinary shell. The first two windows I want rename to "top" and "root". Today I have to hit F8 to do the renaming of the windows.

Revision history for this message
Thomas Vander Stichele (thomasvs) wrote :

Hi Dustin,

any news on this one ? This seems to be a very useful feature; getting tired of having to recreate all my panes with names every time I reboot a virtual machine.

Revision history for this message
Maarten Bollen (maarten-bollen) wrote :

Hi Dustin,

I'm kinda vouching for this option too, please let us know once it is available.

Revision history for this message
Ranko Kohime (rankokohime) wrote :

Has this been fixed as of 5.30?

Revision history for this message
gokcehan (gokcehankara) wrote :

Is this still been monitored? So I'm a tmux user trying to switch to byobu these days and I have a workaround about this like so:

    $ cat ~/.byobu/windows.tmux
    new
    neww -n localhost bash
    neww -n aussie 'ssh root@aussie'
    neww -n beagle 'ssh root@beagle'
    neww -n collie 'ssh root@collie'
    $ cat ~/.byoburc.tmux
    source-file ~/.byobu/windows.tmux

So I was thinking `source-file ~/.byobu/windows.tmux` could be moved to some system directory instead.

There are still 3 problems I could think of:

1-) When I start byobu with the desktop launcher (byobu-launcher) I still need to select the above session using C-a s
2-) `windows.tmux` has the tmux syntax which may or may not be a problem
3-) Need to do something about `$BYOBU_WINDOWS` as well

I think (1) is currently the major problem. When I remove the first line in `windows.tmux`, launcher doesn't attach to anything and close up immediately. Does anyone has an idea how to make it work?

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

:-) Yes, I am still alive and monitoring this. I haven't gotten around to this bug yet, sorry.

Revision history for this message
Ryan Waldroop (ryan.waldroop) wrote :

So I've created a file at ~/.byobu/windows.tmux and added the following:

neww -n top top
neww -n localhost zsh

When I SSH into that server, byobu runs, but top does not show up at the bottom. Then, if I press F6 to disconnect, I return to my local machine.

If I SSH into the server a second time, I get the option to connect to my previous session with 1 window, or another session with 2 windows.

Selecting the option with 2 windows does indeed show top and and zsh running as expected, but why do they not run when byobu first starts?

So I found /usr/share/byobu/profiles/tmuxrc and moved the windows variable to the top of that list. Then it didn't run at all. I tried it in each position but about halfway down it started running as before.

Hope that helps figure this out.

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

bzr commit -m '* usr/bin/byobu.in, usr/share/man/man1/byobu.1: LP: #907363
  - fix custom window support for byobu-tmux' --fixes 'lp:907363'
Committing to: /local/media/src/byobu/byobu/
modified debian/changelog
modified usr/bin/byobu.in
modified usr/share/man/man1/byobu.1
Committed revision 2380.

Changed in byobu:
status: Triaged → Fix Committed
Revision history for this message
Björn Torkelsson (torkel) wrote :

Almost working. Two things though.

1) Using commands that takes options does not work. For instance:

$ cat windows.tmux.test
new-session bash;
new-window -n root 'sudo -i';

I just get an usage message for new-window.

2) I would be nice if lines starting with # was ignored

Changed in byobu:
status: Fix Committed → Fix Released
Revision history for this message
Ryan Waldroop (ryan.waldroop) wrote :

Working much better now. While byobu tmux always creates the session as defined in windows.tmux, it would be great if it searched for a session to attach to first.

Currently, I can run "byobu attach," but can't do that each time because it fails when there is no tmux session to attach to.

I'm going to keep digging and see if I can find a way to write an if/then statement for byobu and byobu launcher.

Revision history for this message
Ryan Waldroop (ryan.waldroop) wrote :

With some help from this site:
https://gist.github.com/chakrit/5004006

I've got byobu+tmux working perfectly for me, using the latest PPA on Trusty that Dusting posted as fixed above. Here's the setup I'm using in case someone finds this bug in the future:

~/.byobu/.tmux.conf

new -s main -n top top;
neww -n zsh zsh;

~/.byobu/windows.tmux

attach;

So I'm using .tmux.conf to actually create the windows I want, and windows.tmux is called after that to attach to the session that's already running. Now, whenever I open the byobu launcher or ssh into my computer, I'm greeted with the same session and the same windows. Closing and re-opening the byobu terminal doesn't re-create tons of sessions and windows.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.