add support for opening session in current directory

This commit is contained in:
Daylin Morgan 2024-12-18 15:58:52 -06:00
parent 0c03398f37
commit 3aa9fb9490
Signed by: daylin
GPG key ID: 950D13E9719334AD

View file

@ -1,14 +1,9 @@
import std/sequtils import std/[sequtils, os]
import ./[selector, project, tmuxutils] import ./[selector, project, tmuxutils, term]
import hwylterm, hwylterm/hwylcli import hwylterm, hwylterm/hwylcli
proc tsm(open: bool = false) = proc tsm(project: Project) =
let if project.name notin tmux.sessions.mapIt(it.name):
projects = findProjects(open)
project = selectProject projects
selected = project.name
if selected notin tmux.sessions.mapIt(it.name):
tmux.new(project.name, project.location) tmux.new(project.name, project.location)
else: else:
tmux.attach project.name tmux.attach project.name
@ -20,7 +15,23 @@ hwylCli:
name "tsm" name "tsm"
V tsmVersion V tsmVersion
flags: flags:
open "only search open sessions" open:
? "only search open sessions"
- o
new:
? "open session in current directory"
- n
run: 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)