mirror of
https://github.com/daylinmorgan/tsm.git
synced 2024-12-22 13:10:43 -06:00
refactor: use template
This commit is contained in:
parent
4633b5b01c
commit
c5a8923118
1 changed files with 8 additions and 5 deletions
13
src/tsm.nim
13
src/tsm.nim
|
@ -7,6 +7,9 @@ proc checkExe(names: varargs[string]) =
|
||||||
if findExe(name) == "":
|
if findExe(name) == "":
|
||||||
echo "tsm requires " & name
|
echo "tsm requires " & name
|
||||||
|
|
||||||
|
template tmux(cmd: string) =
|
||||||
|
discard execCmd("tmux " & cmd)
|
||||||
|
|
||||||
proc tsm() =
|
proc tsm() =
|
||||||
checkExe "tmux"
|
checkExe "tmux"
|
||||||
|
|
||||||
|
@ -14,16 +17,16 @@ proc tsm() =
|
||||||
project = selectProject()
|
project = selectProject()
|
||||||
selected = project.name
|
selected = project.name
|
||||||
|
|
||||||
# TODO: refactor
|
|
||||||
if existsEnv("TMUX"):
|
if existsEnv("TMUX"):
|
||||||
if selected notin listTmuxSessions():
|
if selected notin listTmuxSessions():
|
||||||
discard execCmd(&"tmux new-session -d -s {selected} -c {project.location}")
|
tmux &"new-session -d -s {selected} -c {project.location}"
|
||||||
discard execCmd(&"tmux switch-client -t {selected}")
|
else:
|
||||||
|
tmux &"switch-client -t {selected}"
|
||||||
else:
|
else:
|
||||||
if selected notin listTmuxSessions():
|
if selected notin listTmuxSessions():
|
||||||
discard execCmd(&"tmux new-session -s {selected} -c {project.location}")
|
tmux &"new-session -s {selected} -c {project.location}"
|
||||||
else:
|
else:
|
||||||
discard execCmd(&"tmux attach -t {selected}")
|
tmux &"attach -t {selected}"
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
import cligen
|
import cligen
|
||||||
|
|
Loading…
Reference in a new issue