From eb97385d9b6f2679684248915a83d702d56ff66b Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Sat, 30 Sep 2023 19:11:50 -0500 Subject: [PATCH] fix: properly attach to new session --- src/utils.nim | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/utils.nim b/src/utils.nim index 5cc377b..665429b 100644 --- a/src/utils.nim +++ b/src/utils.nim @@ -26,7 +26,7 @@ template cmd(tmux: Tmux, args: string) = proc newTmux(): Tmux = result.active = existsEnv("TMUX") # check if server is active? - if execCmd("tmux run") == 0: + if execCmdEx("tmux run").exitCode == 0: result.sessions = ( result.cmdGet "list-sessions -F '#S'" ).strip().split("\n") @@ -38,9 +38,11 @@ proc attach*(t: Tmux, session: string) = t.cmd fmt"{args} {session}" proc new*(t: Tmux, session: string, loc: string) = - let args = - if t.active: "new-session -d" - else: "new-session" - t.cmd fmt"{args} -s {session} -c {loc}" + if t.active: + t.cmd fmt"new-session -d -s {session} -c {loc}" + t.attach session + else: + t.cmd fmt"new-session -s {session} -c {loc}" + let tmux* = newTmux()