Skip to content

plugin: add optional suffix to tds for multiple tmux sessions per directory - #780

Closed
senderic wants to merge 20 commits into
ohmybash:masterfrom
senderic:tmux-session-name-suffix-clean
Closed

senderic wants to merge 20 commits into
ohmybash:masterfrom
senderic:tmux-session-name-suffix-clean

Conversation

@senderic

Copy link
Copy Markdown

Summary

Allow tds to accept an optional suffix argument so users can create multiple tmux sessions for the same directory (e.g., tds codex, tds claude). The session name format becomes {dirname}-{hash}-{suffix} when a suffix is provided.

Also added tdss alias as a dedicated command for the same functionality.

Changes

  • Modified plugins/tmux/tmux.plugin.bash: Updated _omb_plugin_tmux_directory_session function to accept optional suffix argument; added _omb_plugin_tmux_directory_session_suffix function and tdss alias
  • Modified plugins/tmux/README.md: Updated documentation for tds and added tdss alias

Testing

Tested locally with oh-my-bash:

  • tds creates session {dirname}-{hash}
  • tds codex creates session {dirname}-{hash}-codex
  • tds claude creates session {dirname}-{hash}-claude
  • tdss codex works the same way

senderic and others added 19 commits July 14, 2026 20:48
Implement auto-completion support for terraform aliases (`t`, `tapply`,
`tplan`, `tinit`, `tfmt`).

- Since the terraform CLI binary (`complete -C`) does not support flag
  completion out of the box, intercept completions starting with `-` to
  provide static suggestions for common flags of the relevant subcommand.
- Fallback to delegating completions to the registered terraform specification,
  carefully translating context arguments (shifting `cur`/`prev`), parsing
  quoted complete paths, and properly restoring shell completion environments.
Implement auto-completion support for terraform aliases (`t`, `tapply`,
`tplan`, `tinit`, `tfmt`).

- Since the terraform CLI binary (`complete -C`) does not support flag
  completion out of the box, intercept completions starting with `-` to
  provide static suggestions for common flags of the relevant subcommand.
- Fallback to delegating completions to the registered terraform specification,
  carefully translating context arguments (shifting `cur`/`prev`), parsing
  quoted complete paths, and properly restoring shell completion environments.
Address review feedback for the terraform alias completion function:
- Add an early guard to return 1 when COMP_CWORD is 0, preventing pointing
  at the wrong expanded word during command token completion.
- Verify the existence of the delegated completion function (real_func)
  using [_omb_util_function_exists](cci:1://file:///home/g56147/.oh-my-bash/lib/utils.sh:118:0-120:1) before executing it.
- Remove the unused local variable `prev` to clean up dead code.
- Add early return guard when `COMP_CWORD == 0` to prevent incorrect word shifting during command-token completion.
- Verify delegated function existence using [_omb_util_function_exists](cci:1://file:///home/g56147/.oh-my-bash/lib/utils.sh:118:0-120:1) before invocation.
- Clean up unused `prev` local variable block.
feat(tmux): add bash completion for tmux_resume
feat(terraform): add flag auto-completion for subcommand aliases
Introduces a dual Bash/Zsh-compatible autocomplete script at custom/devin-fed.sh.
Supports fast models completion using models.cache (loaded in 4ms), dynamic active sessions completion for `--resume` / `-r`, and full hierarchical completion for subcommands and flags.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…ectory

Allow tds to accept an optional suffix argument so users can create
multiple tmux sessions for the same directory (e.g., 'tds codex',
'tds claude'). The session name format becomes
{dirname}-{hash}-{suffix} when a suffix is provided.

Also add tdss alias as a dedicated command for the same functionality.
@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Support suffixed tmux directory sessions and session completion

✨ Enhancement 📝 Documentation 🕐 10-20 Minutes

Grey Divider

AI Description

• Allows optional suffixes for parallel per-directory tmux sessions.
• Adds tdss as a dedicated suffix-aware command.
• Completes session names for attach and kill aliases.
Diagram

graph TD
  CMD["tds / tdss"] --> BUILD["Directory functions"] --> HASH{"Hash tool?"}
  HASH -->|Available| NAME["Session name"] --> TMUX["tmux session"]
  HASH -->|Missing| ERROR["Command error"]
  ALIASES["ta tad tkss"] --> COMPLETE["Session completion"] --> TMUX
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Share one directory-session implementation
  • ➕ Eliminates duplicated hashing and session-name construction logic.
  • ➕ Prevents tds and tdss behavior from diverging.
  • ➕ Retains both user-facing aliases with less maintenance overhead.
  • ➖ Error messages cannot identify the invoked alias without passing additional context.
  • ➖ Requires deciding whether tdss should remain distinct from tds semantically.
2. Separate session completion change
  • ➕ Keeps the PR focused on suffixed directory sessions.
  • ➕ Allows completion behavior and escaping to be reviewed and tested independently.
  • ➖ Requires another PR and delays availability of the completion enhancement.

Recommendation: Use _omb_plugin_tmux_directory_session as the single suffix-aware implementation and point both tds and tdss to it. The completion addition is useful but orthogonal; it should either receive targeted tests here or move to a focused follow-up.

Files changed (2) +43 / -2

Enhancement (1) +41 / -1
tmux.plugin.bashAdd suffixed sessions, tdss, and alias completion +41/-1

Add suffixed sessions, tdss, and alias completion

• Extends 'tds' session names with an optional first-argument suffix and adds equivalent functionality through 'tdss'. It also registers session-name completion for 'ta', 'tad', and 'tkss'.

plugins/tmux/tmux.plugin.bash

Documentation (1) +2 / -1
README.mdDocument suffix-aware directory session aliases +2/-1

Document suffix-aware directory session aliases

• Documents optional suffix usage for 'tds' and adds the new 'tdss' command to the alias reference.

plugins/tmux/README.md

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Sep 20, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Mac users attach to the wrong session ✓ Resolved 🐞 Bug ≡ Correctness
Description
_omb_plugin_tmux_directory_session_suffix invokes BSD md5 without -q, then truncates its
formatted output rather than the digest. When md5sum is unavailable, paths with the same basename
and suffix generate the same target, so a later tdss invocation attaches to the earlier
directory's session.
Code

plugins/tmux/tmux.plugin.bash[R58-59]

+  elif _omb_util_command_exists md5; then
+    md5=$(printf '%s' "$PWD" | md5)
Evidence
The new helper captures plain md5 output and slices it when constructing the session name.
Elsewhere, the repository explicitly uses md5 -q on Darwin while using md5sum | cut on other
systems, demonstrating that the quiet flag is required to obtain the raw BSD digest.

plugins/tmux/tmux.plugin.bash[53-67]
completions/gradle.completion.sh[9-15]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new `tdss` helper uses formatted BSD/macOS `md5` output, making its six-character hash prefix constant and allowing same-named directories to collide.
## Fix Focus Areas
- plugins/tmux/tmux.plugin.bash[53-67]
- plugins/tmux/tmux.plugin.bash[36-39]
## Recommended Fix
Invoke BSD/macOS `md5` with `-q` so only the digest is captured. Prefer making `tdss` delegate to the corrected directory-session helper rather than maintaining a second copy of the hashing logic.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

2. Escaped session names stop completing ✓ Resolved 🐞 Bug ≡ Correctness
Description
_omb_tmux_alias_sessions compares each unescaped session name against the escaped text retained in
COMP_WORDS, while applying %q only after that comparison. Once a user enters an escaped space or
metacharacter in a session-name prefix, the prefix test rejects the matching session for ta,
tad, and tkss.
Code

plugins/tmux/tmux.plugin.bash[R81-84]

+  for s in "${sessions[@]}"; do
+    [[ $s == "$cur"* ]] || continue
+    printf -v escaped '%q' "$s"  # escapes spaces/glob metachars
+    COMPREPLY+=("$escaped")
Evidence
The function reads cur directly from COMP_WORDS, splits tmux output into raw session strings,
tests the raw string against cur, and only afterward escapes the result. The registered completion
applies this mismatched comparison to all three aliases.

plugins/tmux/tmux.plugin.bash[73-88]
lib/utils.sh[450-457]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new tmux completion compares escaped command-line input with raw session names, preventing continued completion of names containing spaces or shell metacharacters.
## Fix Focus Areas
- plugins/tmux/tmux.plugin.bash[73-85]
## Recommended Fix
Normalize both values before prefix matching. One direct approach is to generate the `%q` form of each session before the test, compare that escaped value with `cur`, and append the same value to `COMPREPLY`; also cover names containing spaces and metacharacters with completion tests.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread plugins/tmux/tmux.plugin.bash Outdated
Comment thread plugins/tmux/tmux.plugin.bash
- Use 'md5 -q' on macOS/BSD to get raw digest instead of formatted output
- Consolidate duplicated hashing logic into _omb_plugin_tmux_dir_hash helper
- Make tdss an alias to tds (single implementation)
- Fix completion to compare escaped session names against escaped cur
@senderic
senderic force-pushed the tmux-session-name-suffix-clean branch from 196b41d to 3343409 Compare September 20, 2026 21:25
@senderic senderic closed this Sep 20, 2026
@senderic
senderic deleted the tmux-session-name-suffix-clean branch September 20, 2026 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant