Running emacs on tmux startup

I'm trying to get the hang of tmux, but can't figure out how to bring it up and start an emacs session with that session in the foreground.

I have this in my tmux.conf

new 'emacs -nw

and I can see an emacs session when I press prefix-W and see a number of windows and I can select it then, but I'd like to go directly to it when tmux starts up.

I admit I'm a tmux newbie and don't yet understand the difference between new neww or whether I should start with a 'tmux attach'.

It's all very confusing to me. Most of the videos seem to show how to create/split windows/panes but not much attention seems to be applied to configuration options.
 
After amending tmux.conf to include:

Code:
new  -nemacs 'exec emacs -nw'
selectw -t 0

When I press pfx-w I get as far as:

Code:
(0) - 0:1 windows (attached)
(1) |-> 1: emacs*

then I can select my emacs window, but I'd prefer that the emacs window came up automatically.

What am I missing?
 
My tmux.conf contains:-

new -nemacs 'emacs -nw ~/.config/tmux/tmux.conf'

When I start tmux and press C-b w I get:-

Code:
(0) - 0: 1 windows
(1) └─> 1: emacs*
(2) - 1: 1 windows (attached)
(3) └─> 1: [tmux]*

Emacs has clearly started. When I select it, ie (1) the status window shows:-

[0] 1: emacs*
When I select (3) the status window shows:-

[1] 1: sh*

Pressing next/previous window errors with 'no next/previous window'

I'm clearly missing something regarding sessions, windows and panes...

Any enlightenment would be appreciated.
 
If I get that, You want to keep an emacs running continuously, and use tmux to connect/disconnect to it as need arises?

Code:
(0) - 0: 1 windows
(1) └─> 1: emacs*
(2) - 1: 1 windows (attached)
(3) └─> 1: [tmux]*

Emacs has clearly started. When I select it, ie (1) the status window shows:-

[0] 1: emacs*
When I select (3) the status window shows:-

[1] 1: sh*

Pressing next/previous window errors with 'no next/previous window'
That would be correct. There is only one window here in each session. tmux knows sessions and windows. A session is a terminal screen. A window is an area of that screen that runs a separate shell (or application). Or something along that - I didn't dive deep into that.
 
It's slowly seeping into my understanding of how tmux works... ie
new -nemacs 'emacs -nw ~/.config/tmux/tmux.conf'
appears to start a new session, although I'm not sure what starts the first session.

If I use
neww -nemacs 'emacs -nw ~/.config/tmux/tmux.conf'
I get:
/root/.config/tmux/tmux.conf:41: no current target
so how do set a target for a neww ?
 
That would be correct. There is only one window here in each session. tmux knows sessions and windows. A session is a terminal screen. A window is an area of that screen that runs a separate shell (or application). Or something along that - I didn't dive deep into that.
That wasn't quite right: a session is what a client connects to. A window is a terminal screen inside a session (there can be more than one). And a pane is a rectangular area of that screen that runs a shell or application.
 
That wasn't quite right: a session is what a client connects to. A window is a terminal screen inside a session (there can be more than one). And a pane is a rectangular area of that screen that runs a shell or application.
I guess what I'm looking for to start with is a way to start tmux in a single session with a single window running a program using tmux.conf. Sounds pretty basic but haven't figured it out so far. I must be missing something fundamental.
 
I guess what I'm looking for to start with is a way to start tmux in a single session with a single window running a program using tmux.conf. Sounds pretty basic but haven't figured it out so far. I must be missing something fundamental.

If you want single everything you should use a separate socket for that session.
 
Back
Top