diff --git a/workspaces.py b/workspaces.py index f7158bc..6b304e6 100755 --- a/workspaces.py +++ b/workspaces.py @@ -462,7 +462,6 @@ def list_repos( """ _settings, _repos_dir, workspaces_dir = get_ctx_paths(ctx) ws_dir = find_workspace_dir(workspaces_dir, workspace) - workspace = ws_dir.name if not ws_dir.exists(): console.print( @@ -570,8 +569,6 @@ def add_repo( """ _settings, repos_dir, workspaces_dir = get_ctx_paths(ctx) ws_dir = find_workspace_dir(workspaces_dir, workspace) - workspace = ws_dir.name - if not ws_dir.exists(): console.print( f"[red]Workspace '{ws_dir.name}' does not exist at {ws_dir}[/red]" @@ -774,7 +771,6 @@ def remove_workspace( """ _settings, repos_dir, workspaces_dir = get_ctx_paths(ctx) ws_dir = find_workspace_dir(workspaces_dir, workspace) - workspace = ws_dir.name if not ws_dir.exists(): console.print( @@ -875,7 +871,7 @@ def remove_workspace( shutil.rmtree(wt) if in_tmux(): - session_name = get_session_name(ws_dir, repo) + session_name = f"{ws_dir.name}|{repo.name}" remove_session_if_exists(session_name) # Finally, remove the workspace directory itself shutil.rmtree(ws_dir) @@ -972,8 +968,6 @@ def wip_workspace( """ _settings, _repos_dir, workspaces_dir = get_ctx_paths(ctx) ws_dir = find_workspace_dir(workspaces_dir, workspace) - workspace = ws_dir.name - if not ws_dir.exists(): console.print( f"[red]Workspace '{ws_dir.name}' does not exist at {ws_dir}[/red]" @@ -1016,8 +1010,6 @@ def commit_workspace( raise typer.Exit(1) _settings, _repos_dir, workspaces_dir = get_ctx_paths(ctx) ws_dir = find_workspace_dir(workspaces_dir, workspace) - workspace = ws_dir.name - if not ws_dir.exists(): console.print( f"[red]Workspace '{ws_dir.name}' does not exist at {ws_dir}[/red]" @@ -1096,8 +1088,6 @@ def push_workspace( """ _settings, _repos_dir, workspaces_dir = get_ctx_paths(ctx) ws_dir = find_workspace_dir(workspaces_dir, workspace) - workspace = ws_dir.name - if not ws_dir.exists(): console.print( f"[red]Workspace '{ws_dir.name}' does not exist at {ws_dir}[/red]" @@ -1166,8 +1156,6 @@ def status_workspace( """ _settings, _repos_dir, workspaces_dir = get_ctx_paths(ctx) ws_dir = find_workspace_dir(workspaces_dir, workspace) - workspace = ws_dir.name - if not ws_dir.exists(): console.print( f"[red]Workspace '{ws_dir.name}' does not exist at {ws_dir}[/red]" @@ -1250,7 +1238,6 @@ def diff_workspace( """ _settings, _repos_dir, workspaces_dir = get_ctx_paths(ctx) ws_dir = find_workspace_dir(workspaces_dir, workspace) - workspace = ws_dir.name if not ws_dir.exists(): console.print( @@ -1498,13 +1485,6 @@ def remove_session(session_name: str) -> None: if r.returncode != 0: raise typer.Exit(r.returncode) -def get_session_name(ws_dir: Path, repo: Path): - session_name = f"ω|{ws_dir.name}|{repo.name}" - session_name = session_name.strip().replace(" ", "_").replace(':', '_').replace('.', '_').replace('/', '_') - return session_name - - return result.stdout.decode().strip() - tmux_app = typer.Typer( name="tmux", @@ -1531,23 +1511,15 @@ def tmux_cli_attach( """ _settings, _repos_dir, workspaces_dir = get_ctx_paths(ctx) ws_dir = find_workspace_dir(workspaces_dir, workspace) - workspace = ws_dir.name - if not ws_dir: console.print(f"[red]Workspace '{workspace}' does not exist at {ws_dir}[/red]") raise typer.Exit(1) # pick repo in workspace - repos = [directory for directory in ws_dir.iterdir() if directory.is_dir()] - if not repos: - console.print("[red]No repos found in workspace. Add One.[/red]") - add_repo(ctx=ctx, workspace=workspace, repo_name=None) - repos = [directory for directory in ws_dir.iterdir() if directory.is_dir()] - repo = pick_repo_with_iterfzf(repos) - + repo = pick_repo_with_iterfzf([directory for directory in ws_dir.iterdir() if directory.is_dir()]) if not repo: console.print("[red]No repo selected. Exiting.[/red]") raise typer.Exit(1) - session_name = get_session_name(ws_dir, repo) + session_name = f"ω|{ws_dir.name}|{repo.name}" console.print(f"Session name: {session_name}") create_if_needed_and_attach(session_name, repo, False) @@ -1662,4 +1634,3 @@ def attach( if __name__ == "__main__": app() -