mirror of
https://github.com/daylinmorgan/tsm.git
synced 2024-12-22 13:10:43 -06:00
fix: properly attach to new session
This commit is contained in:
parent
81f7e0b4a8
commit
eb97385d9b
1 changed files with 7 additions and 5 deletions
|
@ -26,7 +26,7 @@ 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?
|
# check if server is active?
|
||||||
if execCmd("tmux run") == 0:
|
if execCmdEx("tmux run").exitCode == 0:
|
||||||
result.sessions = (
|
result.sessions = (
|
||||||
result.cmdGet "list-sessions -F '#S'"
|
result.cmdGet "list-sessions -F '#S'"
|
||||||
).strip().split("\n")
|
).strip().split("\n")
|
||||||
|
@ -38,9 +38,11 @@ proc attach*(t: Tmux, session: string) =
|
||||||
t.cmd fmt"{args} {session}"
|
t.cmd fmt"{args} {session}"
|
||||||
|
|
||||||
proc new*(t: Tmux, session: string, loc: string) =
|
proc new*(t: Tmux, session: string, loc: string) =
|
||||||
let args =
|
if t.active:
|
||||||
if t.active: "new-session -d"
|
t.cmd fmt"new-session -d -s {session} -c {loc}"
|
||||||
else: "new-session"
|
t.attach session
|
||||||
t.cmd fmt"{args} -s {session} -c {loc}"
|
else:
|
||||||
|
t.cmd fmt"new-session -s {session} -c {loc}"
|
||||||
|
|
||||||
|
|
||||||
let tmux* = newTmux()
|
let tmux* = newTmux()
|
||||||
|
|
Loading…
Reference in a new issue