When we attach/create tmux session, we can use "control+b" and use different shortcuts for purpose like listing sessions, create new sessions etc. I don't want that to happen. How to disable the tmux shortcut when attach/create tmux session?
1 Answer
You can try tmux unbind-key -a to remove all key bindings. Note also that
tmux attach -r gives you a readonly view of a session.
You can give many commands at the start by separating them by a semi-colon, which you must quote with backslash to avoid the shell from interpreting it. For example:
tmux new-session -s mysession\; unbind-key -a
-
Thank you for the reply. Is there any way to create the new-session or new-window if we start the session by unbinding all keys? Jul 16, 2018 at 16:25
-
You can give many commands at the start by separating them by a semi-colon, which you must quote with backslash to avoid the shell from interpreting it. Eg
tmux new-session -s mysession\; unbind-key -a– meuhJul 16, 2018 at 17:36 -
@Niraj You can run
tmuxto send specific commands to an arbitrary session, but it's a lot easier to use the keyboard shortcuts. Why do you want to disable the shortcuts? Perhaps you just want a prefix that doesn't interfere with a binding you already use.– chepnerJul 16, 2018 at 17:37 -
I want to use the feature of keeping SSH session running. I don't want user to create the new sessions, new windows within the session. This is required for security. So idea is, on user login, we will attach the user to the already running session if exists. If session don't exists on user login, we will create a new session. Now user is connected and he can create a new session/window using shortcut, which we don't want to happen. Again we can not open session in read only mode as we want to give some input to the process running in session. Now i am able to stop all shortcuts using unbind. Jul 17, 2018 at 5:00
-
Just wanted to know is there any other way to open new session/windows from already connected session if all shortcuts are disabled ? I know we can use tmux command to create the new session/window from already running session. But in our case, user will not have access to the shell as we will directly attach user to the already running session or create new session upon login. Jul 17, 2018 at 5:05