mirror of
https://github.com/daylinmorgan/tsm.git
synced 2024-12-22 13:10:43 -06:00
fix: don't get session list if not running
This commit is contained in:
parent
f2ddcac75f
commit
947847459d
1 changed files with 6 additions and 4 deletions
|
@ -25,13 +25,15 @@ template cmd(tmux: Tmux, args: string) =
|
||||||
|
|
||||||
proc newTmux(): Tmux =
|
proc newTmux(): Tmux =
|
||||||
result.active = existsEnv("TMUX")
|
result.active = existsEnv("TMUX")
|
||||||
|
# check if server is active?
|
||||||
|
if execCmd("tmux run") == 0:
|
||||||
result.sessions = (
|
result.sessions = (
|
||||||
result.cmdGet "list-sessions -F '#S'"
|
result.cmdGet "list-sessions -F '#S'"
|
||||||
).strip().split("\n")
|
).strip().split("\n")
|
||||||
|
|
||||||
proc attach*(t: Tmux, session: string) =
|
proc attach*(t: Tmux, session: string) =
|
||||||
let args =
|
let args =
|
||||||
if t.active:"switch-client -t"
|
if t.active: "switch-client -t"
|
||||||
else: "attach -t"
|
else: "attach -t"
|
||||||
t.cmd fmt"{args} {session}"
|
t.cmd fmt"{args} {session}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue