fix: tmux sessions wont attach with . in name
This commit is contained in:
parent
8ba6fe6f8a
commit
97bb6f788d
2 changed files with 13 additions and 1 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
__pycache__
|
||||
|
|
@ -524,6 +524,8 @@ def pick_workspace_with_iterfzf(workspaces: list[Path]) -> Path | None:
|
|||
"""Use iterfzf (Python library) to pick a workspace from a list of paths.
|
||||
"""
|
||||
names = [w.name for w in workspaces]
|
||||
if not names:
|
||||
return None
|
||||
choice = iterfzf(names, prompt="pick a workspace> ")
|
||||
|
||||
if not choice:
|
||||
|
|
@ -1434,6 +1436,7 @@ def create_if_needed_and_attach(
|
|||
- If session doesn't exist: create_detached_session()
|
||||
- Then `tmux switch-client -t session_name`
|
||||
"""
|
||||
session_name = session_name.strip().replace(" ", "_").replace(':', '_').replace('.', '_').replace('/', '_')
|
||||
if not_in_tmux():
|
||||
r = run_tmux(
|
||||
["new-session", "-As", session_name, "-c", str(path_name)],
|
||||
|
|
@ -1503,7 +1506,8 @@ def tmux_cli_attach(
|
|||
),
|
||||
),
|
||||
):
|
||||
"""Attach or create a session for a repo in a workspace.
|
||||
"""
|
||||
Attach or create a session for a repo in a workspace.
|
||||
"""
|
||||
_settings, _repos_dir, workspaces_dir = get_ctx_paths(ctx)
|
||||
ws_dir = find_workspace_dir(workspaces_dir, workspace)
|
||||
|
|
@ -1608,6 +1612,13 @@ def attach(
|
|||
),
|
||||
),
|
||||
):
|
||||
_settings, _repos_dir, workspaces_dir = get_ctx_paths(ctx)
|
||||
if len(list_workspaces(workspaces_dir)) == 0:
|
||||
import sys
|
||||
cmd = sys.executable
|
||||
console.print("[red]No workspaces found. Exiting.[/red]")
|
||||
console.print(f"Create a workspace with `[yellow]workspaces create[/yellow]` first.")
|
||||
raise typer.Exit(1)
|
||||
if in_tmux():
|
||||
tmux_cli_attach(ctx, workspace)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue