From 5c5d2c4927d207ea31ed88fd54e2b873350c06f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Gremaud?= Date: Tue, 28 May 2024 01:09:36 +0200 Subject: [PATCH] Ignore non .ini files, exit on no selection --- tmux_ssh_group.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tmux_ssh_group.py b/tmux_ssh_group.py index 91b21d8..849c42f 100644 --- a/tmux_ssh_group.py +++ b/tmux_ssh_group.py @@ -14,6 +14,8 @@ BASE_PATH = Path("~/.ssh-tmux/").expanduser() configs = {} sections = {} for subconffile in os.listdir(BASE_PATH): + if not subconffile.endswith(".ini"): + continue config = configparser.ConfigParser() config.read(BASE_PATH / subconffile) @@ -24,7 +26,11 @@ for subconffile in os.listdir(BASE_PATH): fzf = FzfPrompt() -selected_group = fzf.prompt(sections.keys(), "--cycle")[0] +selections = fzf.prompt(sections.keys(), "--cycle") +if not selections: + sys.exit(0) + +selected_group = selections[0] config = configs[sections[selected_group]]