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).
 
I have this alias in my .zshrc:

alias tm="tmux new-session -A -s ssh_tmux"

When I connect through ssh I run tm to start a new tmux session, or connect to it if it was already started earlier.
 
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.
 
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.
 
Back
Top