File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 1
1
import argparse
2
2
import os
3
+ import pathlib
3
4
import typing as t
4
5
5
6
from libtmux .server import Server
@@ -140,6 +141,17 @@ def command_shell(
140
141
- :attr:`libtmux.Server.attached_sessions`, :attr:`libtmux.Session.attached_window`,
141
142
:attr:`libtmux.Window.attached_pane`
142
143
"""
144
+ # If inside a server, detect socket_path
145
+ env_tmux = os .getenv ("TMUX" )
146
+ if env_tmux is not None and isinstance (env_tmux , str ):
147
+ env_socket_path = pathlib .Path (env_tmux .split ("," )[0 ])
148
+ if (
149
+ env_socket_path .exists ()
150
+ and args .socket_path is None
151
+ and args .socket_name is None
152
+ ):
153
+ args .socket_path = str (env_socket_path )
154
+
143
155
server = Server (socket_name = args .socket_name , socket_path = args .socket_path )
144
156
145
157
server .raise_if_dead ()
You can’t perform that action at this time.
0 commit comments