Comments (18)
The solution is simple, nest TMUX inside TMate. Unfortunately the information above on how to do this seem rather complicated. Here is my take to add to the confusion and maybe it will help someone.
First understand your TMUX prefix key. By default this is CTRL-B In the following examples I have choosen to use CTRL-Space by use of this command in my .tmux.conf
file:
set-option -g prefix C-Space
Next in your .tmate.conf
file you have to change this. I choose CTRL-y in these examples. First unbind the prefix you set in .tmux.conf
and redefine the prefix in .tmate.conf
To make things even better I've taken the extra step of unbinding keys that I want to pass directly through to TMUX and turning the status off (as nesting would normally produce two status bars). Here is my full .tmate.conf
file:
unbind-key C-Space
set-option -g prefix C-y
bind-key C-y send-prefix
unbind -n C-h
unbind -n C-j
unbind -n C-k
unbind -n C-l
set-option -g status off
Lastly, when I launch I do so in two steps. Since I live in TMUX normally I typically will detach and reattach inside tmate when I need. Alternatively I could also launch a new session inside tmate if I wish. The trick is when inside tmate to always prefix my TMUX commands with TMUX=
. Here is an example:
$ tmate
------------------- Inside tmate ---------------------
$ TMUX= tmux attach
from tmate.
This should be easy to do once tmate decouples itself from tmux (a regular tmux attach inside a tmate session will be sufficient). Thank you @sukima for providing some guidance around this issue.
from tmate.
I don't see how to share an existing tmux session properly :/
Any ideas?
from tmate.
Before proposing paid offerings, which will most likely be used for production environment, I need to do a bit of work. I need to restructure the whole server-side, to allow reconnections, and fault tolerance (if one of my server dies). The new pipeline will also allow incorporation of websockets (for the HTML5 stuff), and session recording (probably to Cassandra, with fulltext search done with Elasticsearch).
Not to worry, the free pairing feature will never go away.
Thanks for the support :)
from tmate.
This is not possible.
What you could do instead is always run tmate.
from tmate.
@nviennot i've thought about this, but it appears tmate ls
does not make it easy for my to re-attach to my existing local tmate sessions
from tmate.
I see.
I guess I'll have to implement multi sessions to make it work :)
from tmate.
multiple sessions would be nice
from tmate.
I have some paper deadline to deal with at the moment, I will give tmate some love soon.
from tmate.
This feature would be awesome 😸
This is exactly the kind of the feature I am willing to pay a yearly subscription for!
from tmate.
My paper deadline is in two weeks, so I'll give it some thoughts fairly soon :)
from tmate.
Yeah I'd also pay for it.
I always run tmate but then the session times out from time to time then have to close tmate and recreate it which is a bit annoying - would be cool to be able to grab a new session at tmate.io ?
You're doing a great job dude!
from tmate.
You can nest tmux & tmate sessions as much as you like as long as you first set TMUX
to an empty value.
So inside an existing tmux/tmate session, you can run new ones like this:
TMUX='' tmate
TMUX='' tmux
You can also access pre-existing tmux sessions on the machine you're accessing using tmate by using:
TMUX='' tmux list-sessions
TMUX='' tmux attach-session -t SESSION_NAME
You'll need to be careful though because the tmux prefix will always be captured by the outer tmux/tmate session, and you'll need to press it twice to have tmux forward it one level deeper. This means you'll need to press it 2 ^ depth
times in order to reach inner sessions (assuming depth starts at 0).
Basically, when you press Ctrl-B once, you'll be sending commands to the outermost session, pressing it twice will send commands to the one inside it, and to access a session inside that one, you'll need to press it 4 times.
Having to press Ctrl-B Ctrl-B Ctrl-B Ctrl-B Ctrl-N to move between windows is either totally crazy or totally awesome. 😜
However, if you manage your tmux sessions properly you will never need more than 2 levels (ie. max depth = 1).
One way to do this would be to:
- Have your main work done in a tmux session.
- Whenever you need to add a new person, create a tmate session in a different terminal and have them join it and from there attach to your original tmux session.
- You can even setup tmate to use a different prefix so it will stay out of your way while you're using the shared tmux session.
- Profit!
I have a few words of advice though:
- Make sure you can reattach to your nested tmate sessions if you accidentally detach from them by pressing too few or too many Ctrl-B's. #31 should help you avoid locking yourself out.
- Make sure you don't get an infinite recursion of tmux/tmate sessions (ie. attach to a tmux session from within itself). If you do, just use the appropriate combination of Ctrl-B's followed by a Ctrl-D (to detach from the offending session), and then wait a few seconds until tmux sorts the craziness out and returns to normal.
This works for me, and it works pretty well actually. But I cannot guarantee that it will not blow up in your face, so be careful. 👍
from tmate.
Until attach/detach work with tmate I recommend nesting tmux as mentioned by @maljub01. To deal with the nested command key I suggest setting tmate to something other than what is used by tmux. I can recommend using ctrl-] which is telnet's escape sequence.
Basically treat tmate as a sharing container for whatever work you are doing and not for any of it's tmux capabilities.
from tmate.
I to find this solution better, Mainly because tmux is at version 1.9 and when I run tmate I loose many features in the tmux binary that tmate doesn't have.
from tmate.
Ping
from tmate.
Hello, I just implemented a solution but it is quite different. I set up my ~/.bashrc
/~/.zshrc
to open tmux
initially. Here is my initial setup:
# Launch TMUX
# If not running interactively, do not do anything
[[ $- != *i* ]] && return
[[ -z "$TMUX" ]] && exec tmux
tmux_count=$(tmux list-panes | wc -l)
if [[ $tmux_count == 1 ]] ; then
# neofetch
((tmux_count++))
fi
Now I installed tmate
, but I also wanted to execute tmate
inside a tmux
pane. Here's what I did:
# Check if user has opened tmate
if [[ -z "$ZSH_TMATE" ]]
then
# Launch TMUX
# If not running interactively, do not do anything
[[ $- != *i* ]] && return
[[ -z "$TMUX" ]] && exec tmux
tmux_count=$(tmux list-panes | wc -l)
if [[ $tmux_count == 1 ]] ; then
# neofetch
((tmux_count++))
fi
# Alias tmate
export ZSH_TMATE=tmate
alias tmate="gnome-terminal"
else
unset TMUX
unset ZSH_TMATE
exec tmate
fi
First, it checks if a ZSH_TMATE
variable has been set. If no variable is detected, I will set the variable and will alias the tmate
command to open a new gnome-terminal
instance.
It will open a new gnome-terminal
, and on the gnome-terminal
instance, it will check if a ZSH_TMATE
variable is set. It will pass on the else
case because you have set it earlier.
I needed to unset the ZSH_TMATE
variable, because it causes an infinite loop that nests a tmate
instance with another tmate
instance. Not exactly sure why it happens tho, I just experimented it a little.
Working demo:
from tmate.
@sukima thanks you for propose this way. It look likes tmux in tmux or tmux in tmate, your need force reset the $TMUX variable to run nested tmux session !
from tmate.
Related Issues (20)
- Tmate server rejects connections from Paramiko
- Plugin manager not working HOT 1
- Getting Error: Not Found HOT 4
- API key registration fails with HTTP 500 - Internal Server Error HOT 6
- Webhook not working on newer Raspbian or raspberry pi HOT 1
- Invalid session token with github actions
- API KEY ERROR
- VsCode HOT 2
- SFTP support
- Getting fatal:accept failed: Operation not supported on socket
- build system fails to detect msgpack-c 6.0.0
- ctrl+b not being recognized HOT 1
- Window pauses for 30-60 seconds every few minutes
- Enable copying files from tmate session via scp
- How build static tmate?? HOT 1
- Output the connection URL in machine readable (barcode) format? HOT 2
- OpenWrt 21.02.7 Error when connecting the second session.
- tmate only shows a completely blank terminal (plus status bar) after discarding the connection messages HOT 2
- Web-based Authentication for Tmate
- Use Webhook with IFTTT
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tmate.