mirror of
https://github.com/daylinmorgan/tsm.git
synced 2024-12-30 07:40:43 -06:00
add support for opening session in current directory
This commit is contained in:
parent
0c03398f37
commit
3aa9fb9490
1 changed files with 22 additions and 11 deletions
33
src/tsm.nim
33
src/tsm.nim
|
@ -1,14 +1,9 @@
|
|||
import std/sequtils
|
||||
import ./[selector, project, tmuxutils]
|
||||
import std/[sequtils, os]
|
||||
import ./[selector, project, tmuxutils, term]
|
||||
import hwylterm, hwylterm/hwylcli
|
||||
|
||||
proc tsm(open: bool = false) =
|
||||
let
|
||||
projects = findProjects(open)
|
||||
project = selectProject projects
|
||||
selected = project.name
|
||||
|
||||
if selected notin tmux.sessions.mapIt(it.name):
|
||||
proc tsm(project: Project) =
|
||||
if project.name notin tmux.sessions.mapIt(it.name):
|
||||
tmux.new(project.name, project.location)
|
||||
else:
|
||||
tmux.attach project.name
|
||||
|
@ -20,7 +15,23 @@ hwylCli:
|
|||
name "tsm"
|
||||
V tsmVersion
|
||||
flags:
|
||||
open "only search open sessions"
|
||||
open:
|
||||
? "only search open sessions"
|
||||
- o
|
||||
new:
|
||||
? "open session in current directory"
|
||||
- n
|
||||
run:
|
||||
tsm(open)
|
||||
if new and open:
|
||||
termQuit "--new and --open are mutually exclusive"
|
||||
|
||||
let project =
|
||||
if new: newProject(
|
||||
path = getCurrentDir(),
|
||||
open = false,
|
||||
)
|
||||
else:
|
||||
selectProject findProjects(open)
|
||||
|
||||
tsm(project)
|
||||
|
||||
|
|
Loading…
Reference in a new issue