From c5a89231181a6b30ddb933e5415c779c0f5fc44c Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Tue, 5 Sep 2023 17:02:08 -0500 Subject: [PATCH] refactor: use template --- src/tsm.nim | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/tsm.nim b/src/tsm.nim index 3ea129f..df2d5c1 100644 --- a/src/tsm.nim +++ b/src/tsm.nim @@ -7,6 +7,9 @@ proc checkExe(names: varargs[string]) = if findExe(name) == "": echo "tsm requires " & name +template tmux(cmd: string) = + discard execCmd("tmux " & cmd) + proc tsm() = checkExe "tmux" @@ -14,16 +17,16 @@ proc tsm() = project = selectProject() selected = project.name - # TODO: refactor if existsEnv("TMUX"): if selected notin listTmuxSessions(): - discard execCmd(&"tmux new-session -d -s {selected} -c {project.location}") - discard execCmd(&"tmux switch-client -t {selected}") + tmux &"new-session -d -s {selected} -c {project.location}" + else: + tmux &"switch-client -t {selected}" else: if selected notin listTmuxSessions(): - discard execCmd(&"tmux new-session -s {selected} -c {project.location}") + tmux &"new-session -s {selected} -c {project.location}" else: - discard execCmd(&"tmux attach -t {selected}") + tmux &"attach -t {selected}" when isMainModule: import cligen