From 947847459da7fd12986dec7cf073756d40563dc2 Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Mon, 25 Sep 2023 12:24:39 -0500 Subject: [PATCH] fix: don't get session list if not running --- src/utils.nim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/utils.nim b/src/utils.nim index dd77448..5cc377b 100644 --- a/src/utils.nim +++ b/src/utils.nim @@ -25,13 +25,15 @@ template cmd(tmux: Tmux, args: string) = proc newTmux(): Tmux = result.active = existsEnv("TMUX") - result.sessions = ( - result.cmdGet "list-sessions -F '#S'" - ).strip().split("\n") + # check if server is active? + if execCmd("tmux run") == 0: + result.sessions = ( + result.cmdGet "list-sessions -F '#S'" + ).strip().split("\n") proc attach*(t: Tmux, session: string) = let args = - if t.active:"switch-client -t" + if t.active: "switch-client -t" else: "attach -t" t.cmd fmt"{args} {session}"