mirror of
https://github.com/prdlk/dotfiles.git
synced 2026-11-02 11:32:42 +00:00
feat(cli): add --new flag to start new omp session
This commit is contained in:
1 parent
d63da34aef
commit
0da56bed45
1 file changed
+14
-5
@@ -20,11 +20,13 @@ Cable entry points:
|
||||
omp-session --list one "display<TAB>session file" record per session
|
||||
omp-session --preview FILE title, cwd, and the conversation's message text
|
||||
omp-session --resume FILE the cable's enter action: `omp --resume FILE`
|
||||
omp-session --new the cable's ctrl-n action: a new `omp` session
|
||||
|
||||
Env:
|
||||
OMP_SESSION_STATE=FILE --resume writes `ran` to it, so the launcher can tell
|
||||
a resumed session from a cancelled picker and only
|
||||
move the cursor back up after a cancel (tv --inline).
|
||||
OMP_SESSION_STATE=FILE --resume/--new write `ran` to it, so the launcher can
|
||||
tell a started session from a cancelled picker and
|
||||
only move the cursor back up after a cancel (tv
|
||||
--inline).
|
||||
PI_CODING_AGENT_DIR omp's agent dir (default ~/.omp/agent).
|
||||
"""
|
||||
|
||||
@@ -219,10 +221,14 @@ def cmd_preview(path):
|
||||
print(f"\n{colors[role]}▌ {role}\033[0m\n{text}")
|
||||
|
||||
|
||||
def cmd_resume(path):
|
||||
def mark_ran():
|
||||
state = os.environ.get("OMP_SESSION_STATE")
|
||||
if state:
|
||||
Path(state).write_text("ran\n")
|
||||
|
||||
|
||||
def cmd_resume(path):
|
||||
mark_ran()
|
||||
os.execvp("omp", ["omp", "--resume", str(path)])
|
||||
|
||||
|
||||
@@ -230,6 +236,7 @@ def cmd_resume(path):
|
||||
|
||||
|
||||
def new_session():
|
||||
mark_ran()
|
||||
os.execvp("omp", ["omp"])
|
||||
|
||||
|
||||
@@ -279,8 +286,10 @@ def main(argv):
|
||||
cmd_preview(argv[1])
|
||||
elif argv[0] == "--resume" and len(argv) == 2:
|
||||
cmd_resume(argv[1])
|
||||
elif argv == ["--new"]:
|
||||
new_session()
|
||||
else:
|
||||
sys.exit("usage: omp-session [--list | --preview FILE | --resume FILE]")
|
||||
sys.exit("usage: omp-session [--list | --preview FILE | --resume FILE | --new]")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user