Need help with tmux

I only just heard about tmux in the last few months and wish I had heard about it years ago. It's now part of my daily toolkit. However I still can't figure out how to make it start the way I want automatically and keep going through the same procedure when I start it.

Hopefully someone could give me some guidance on achieving the following:-

On startup, I want to start emacs, and midnight commander in their own windows and start a third window split vertically. I've tried to achieve this through the config file but have never managed, I keep doing it manually.

I thought I might be able to start mc in a window by running tmux new 'exec mc' but tmux exits immediately.

Any pointers would be appreciated.
 
Is this of any use? An old stackexchange thread.


Also, this one seems to be a whole course on it. (Not as intimidating as it sounds).
 
Hello,

i dont use tmux anymore but was it not something like tmux new-session -d -s session-name the-command?
tmux new -s test -n FreeBSD

starts a shell but immediately exits if I add a command. I guess I'm not specifying command correctly... I've tried numerous ways.
 
tmux new-session -d mc \; split-window -h emacs \; attach

tmux commands separated by a semicolon (slash + semicolon). Read the tmux(1) for all commands. You can also specify a file with commands (the command source-file [-q] path, where path is a text file containig commands)
 
tmux new -s test -n FreeBSD

starts a shell but immediately exits if I add a command. I guess I'm not specifying command correctly... I've tried numerous ways.
I had been trying using mc and it hadn't been working, but it worked with nano. Now I've just realised that I'm using mc as an alias for
env SHELL=/usr/local/bin/bash mc
which must be causing the problem.
 
tmux new-session -d mc \; split-window -h emacs \; attach

tmux commands separated by a semicolon (slash + semicolon). Read the tmux(1) for all commands. You can also specify a file with commands (the command source-file [-q] path, where path is a text file containig commands)
How can I achieve that with an entry in my tmux.conf ?

I've tried various combination but none have worked so far.
 
How can I achieve that with an entry in my tmux.conf ?
You can also write the commands with tmux one after the other:

tmux new-session -d mc
tmux split-window -h emacs
tmux attach
May be you must append session or window id with -t or -s.

But you still did not answer my question: why is tmux so importat for you? Are you running X11?
 
You can also write the commands with tmux one after the other:


May be you must append session or window id with -t or -s.

But you still did not answer my question: why is tmux so importat for you? Are you running X11?

Sometimes I use Xterm, sometimes I just use the (sh) shell.
 
But what do you win with tmux? Under what circumstances you use it?

Tmux is not so bad, there is people that run everything on a separate virtual machine, but what do you win?
It’s a detachable console, so if you’re working on something over SSH, you can detach, and come back to it later from elsewhere or from an X11 session, etc. In addition you can have multiple panes or windows, broadcast commands to multiple panes (for managing multiple machine) and more.

And it’s nothing like a virtual machine at all, it is a detachable console season.
 
It’s a detachable console, so if you’re working on something over SSH, you can detach, and come back to it later from elsewhere or from an X11 session, etc. In addition you can have multiple panes or windows, broadcast commands to multiple panes (for managing multiple machine) and more.
Indeed. But if the concern of balanga is starting some software anytime he restarts tmux, then the first is not his case.
And if he is using X11, then tmux makes also not much sense. For the second case, if one is using a desktop PC,
one can use the virtual terminals with Fn that FreeBSD offer. And since the OP is starting emacs in tmux, he
could also start emacs without tmux and run apps under M-x shell or M-x term in the
second case.

And yes, it is not a virtual machine, but similar is the (mis)use of it as background to run other program (just because
it is cool?)

Well, I just wanted to see if there is other advantage using tmux than these two ...
 
But if the concern of balanga is starting some software anytime he restarts tmux, then the first is not his case.
Right, I don’t think that’s the design intention for .conf, which is why I suggested an alias or tiny script. (That’s how I launch pre-configured session, to be sure.)

But running things in the background that sometimes need terminal interaction is a wonderful use case for tmux — vm-bhyve does this and it’s wonderful. Certainly a lower overhead approach than running it in a xterm of some flavor.

Not sure why the hate for tmux. If you’re more of a console person than a GUI person, it’s fantastic. It’s typically one of those tools that when you learn it, you day “I wish I knew about this earlier.” To each their own.
 
Not sure why the hate for tmux.
Hate?! Absolutely no hate for tmux. I am very aware for what it is needed.

I used emacs in a VT100 Terminal and know the great value of switching the editing files, splitting the terminal.

I also recognize the value of tmux when you do not want to close your programs before logout, because
after the next login you want to continue. This presupposes that the computer is not shut down.

I know the tool, at least some basics. Perhaps a little more than the OP.
But that is no reason to use it where I do not need it.

Do you think the advantage is, that tmux has less overhead than, say, an xterm? Perhaps this is the answer.
 
But what do you win with tmux? Under what circumstances you use it?
It allows me to have multiple windows available at the same time with easy access.

I use it all the time for maintainance and file management and a thousand other things.

It should have been the first thing I learnt about when I started using FreeBSD. It would have saved me so much time.
 
I use tmux under xterm because I can flip between windows using c-< or c-> . Without xterm it is c-b < or c-b >
That seems to be your configuration.

Are you using a tiling windows managers?

I do use tmux, very helpful for many things, but I have the feeling that you are exaggerating with your specific use.
 
That seems to be your configuration.

Can I alter my configuration so that tmux works the same under xterm as it does under sh?
Are you using a tiling windows managers?

I do use tmux, very helpful for many things, but I have the feeling that you are exaggerating with your specific use.
I use LXDE which is a very basic WM.

tmux is something I use all the time. I'm lost without it now that I've found it, although I'm sure I'm not making as much of it as I could. Basically I'm still getting to grip with how it works.
 
Sir say no more tmux-ressurrect plugin call it a day....


My Tmux is little crazy like 9 different sessions 4 window on most of them and like 2-4 pane on each all of that loads up automatically with resurrect.

:beer::beer:

I also have this


Some of the commands under the hood, you make it once and resurrect will do it....

tmux new-session -s programs -n startup \; split-window -v \; selectp -t 0 \; split-window -h\; selectp -t 2 \; split-window -h\; selectp -t 3 \; split-window -h \; selectp -t 1 \; split-window -h &

☝️
1 Window / 6 different panes.


tmux new-session -s VM_Jails -n BASE_00 \; split-window -v \; selectp -t 0 \; split-window -h \; selectp -t 2 \; split-window -h \; new-window -n BASE_01 \; split-window -v \; selectp -t 0 \; split-window -h\; selectp -t 2 \; split-window -h \; new-window -n BASE_02 \; split-window -v \; selectp -t 0 \; split-window -h \; selectp -t 2 \; split-window -h \; new-window -n BASE_03 \; split-window -v \; selectp -t 0 \; split-window -h \; selectp -t 2 \; split-window -h &

☝️
4 windows = 4 different panes on each
 
Can I alter my configuration so that tmux works the same under xterm as it does under sh?
I am not expert in tmux, and intentionally I do not want to configure it (too much), prefer defaults.

tmux commands keys begin with a prefix, default C-B. I really wonder that you can send C-< without a prefix as C-B <.
Perhaps configuration of your wm?

I would think it has sense to use tmux more under a tiling wm. I still do not understand your use of it.
 
Sir say no more tmux-ressurrect plugin call it a day....


My Tmux is little crazy like 9 different sessions 4 window on most of them and like 2-4 pane on each all of that loads up automatically with resurrect.

:beer::beer:

I also have this


Some of the commands under the hood, you make it once and resurrect will do it....



☝️
1 Window / 6 different panes.


tmux new-session -s VM_Jails -n BASE_00 \; split-window -v \; selectp -t 0 \; split-window -h \; selectp -t 2 \; split-window -h \; new-window -n BASE_01 \; split-window -v \; selectp -t 0 \; split-window -h\; selectp -t 2 \; split-window -h \; new-window -n BASE_02 \; split-window -v \; selectp -t 0 \; split-window -h \; selectp -t 2 \; split-window -h \; new-window -n BASE_03 \; split-window -v \; selectp -t 0 \; split-window -h \; selectp -t 2 \; split-window -h &

☝️
4 windows = 4 different panes on each
Sounds like you are a Tmux Guru.

I'll see if I can make some sense of all that.

I'm already getting a headache just looking at that lot.

Are these seperate tmux commands?

Can I just paste this into something like tmux.sh ?

sh:
tmux new-session -s programs -n startup \; split-window -v \; selectp -t 0 \; split-window -h\; selectp -t 2 \; split-window -h\; selectp -t 3 \; split-window -h \; selectp -t 1 \; split-window -h &
 
Back
Top