Skip to content

Commit d6b3d46

Browse files
committed
improve cli completion for configs
1 parent 45c2373 commit d6b3d46

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

tmuxp/cli.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -323,19 +323,15 @@ def complete(cline, cpoint):
323323
dest='ctexta',
324324
nargs='*',
325325
type=str,
326-
default=None,)
327-
326+
default=None,
327+
)
328328

329329
args = parser.parse_args()
330+
ctext = cline.replace('tmuxp ', '')
330331

331332
commands = []
332-
333-
334333
commands.extend(['attach-session', 'kill-session', 'load'])
335334

336-
ctext = cline.replace('tmuxp ', '')
337-
338-
339335
commands = [c for c in commands if ctext in c]
340336

341337
if args.socket_path:
@@ -355,15 +351,20 @@ def session_complete(command, commands, ctext):
355351
ctext_attach = ctext.replace(command + ' ', '')
356352

357353
sessions = [s.get('session_name') for s in t._sessions]
358-
commands.extend([c for c in sessions if ctext_attach in c])
354+
#commands.extend([c for c in sessions if ctext_attach in c])
355+
356+
#commands = [c for c in commands if ctext_subcommand_args in c]
357+
commands = [c for c in commands if c.startswith(ctext_attach)]
359358

360359
def config_complete(command, commands, ctext):
361360
if ctext.startswith(command + ' '):
362361
commands[:] = []
363362
ctext_subcommand_args = ctext.replace(command + ' ', '')
364-
commands += config.in_dir(config_dir)
365-
commands += config.in_cwd()
366-
commands = [c for c in commands if ctext_subcommand_args in c]
363+
configs = []
364+
configs += config.in_cwd()
365+
configs += config.in_dir(config_dir)
366+
#commands = [c for c in commands if ctext_subcommand_args in c]
367+
commands += [c for c in configs if c.startswith(ctext_subcommand_args)]
367368

368369
session_complete('attach', commands, ctext)
369370
session_complete('kill-session', commands, ctext)

0 commit comments

Comments
 (0)