Skip to content

Commit e5791e5

Browse files
committed
Try a fix #20
1 parent 838dc11 commit e5791e5

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ Here you can find the recent changes to tmuxp.
1010
''''''''''
1111

1212
- [cli] accept ``-y`` argument to answer yes to questions. `#19`_
13+
- [cli] :meth:`cli.SessionCompleter` no longer allows a duplicate session
14+
after one is added.
1315
- [docs] ongoing work on :ref:`about_tmux`.
1416

1517
.. _#19: https://github.com/tony/tmuxp/pull/19
18+
.. _#20: https://github.com/tony/tmuxp/issues/19
1619

1720
2013-11-09
1821
''''''''''

tmuxp/cli.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,12 @@ def __call__(self, prefix, **kwargs):
165165
)
166166

167167
tmuxinator_configs = config.in_dir(
168-
tmuxinator_config_dir, extensions='yml')
169-
completion += [os.path.join(tmuxinator_config_dir, f)
170-
for f in tmuxinator_configs]
168+
tmuxinator_config_dir, extensions='yml'
169+
)
170+
completion += [
171+
os.path.join(tmuxinator_config_dir, f)
172+
for f in tmuxinator_configs
173+
]
171174

172175
return completion
173176

@@ -182,8 +185,10 @@ def __call__(self, prefix, **kwargs):
182185
)
183186

184187
teamocil_configs = config.in_dir(teamocil_config_dir, extensions='yml')
185-
completion += [os.path.join(teamocil_config_dir, f)
186-
for f in teamocil_configs]
188+
completion += [
189+
os.path.join(teamocil_config_dir, f)
190+
for f in teamocil_configs
191+
]
187192

188193
return completion
189194

@@ -196,8 +201,18 @@ def SessionCompleter(prefix, parsed_args, **kwargs):
196201
socket_path=parsed_args.socket_path
197202
)
198203

199-
return [s.get('session_name') for s in t._sessions
200-
if s.get('session_name').startswith(prefix)]
204+
sessions_available = [
205+
s.get('session_name') for s in t._sessions
206+
if s.get('session_name').startswith(' '.join(prefix))
207+
]
208+
209+
if parsed_args.session_name and sessions_available:
210+
return []
211+
212+
return [
213+
s.get('session_name') for s in t._sessions
214+
if s.get('session_name').startswith(prefix)
215+
]
201216

202217

203218
def setup_logger(logger=None, level='INFO'):

0 commit comments

Comments
 (0)