feat(tmux): focus tmux agent session on toggle#317
Open
MartinLoeper wants to merge 1 commit into
Open
Conversation
Co-authored-by: Codex <noreply@openai.com>
Author
DemoReplay_2026-05-07_00-26-10.mp4 |
Author
|
I find the workflow above really convenient as I think it makes sense to reuse the muscle memory around $HOME/scripts/tmux-editor-toggle: #!/usr/bin/env bash
# Toggle to/from the editor (lvim/nvim) window in the current tmux session.
# - If already in an editor window: forward C-. to the pane so nvim/sidekick handles it.
# - Otherwise: switch to the first lvim/nvim window in the session.
# - If no editor window exists: open lvim in a new window using the current pane's cwd.
CURRENT_NAME=$(tmux display-message -p '#{window_name}')
if [[ "$CURRENT_NAME" =~ ^(lvim|nvim) ]]; then
# Send the literal CSI-u sequence for C-. (period=46, mods=ctrl=5) to the pane.
# send-keys writes to the pty directly, bypassing tmux's own key bindings.
tmux send-keys -l $'\e[46;5u'
exit 0
fi
EDITOR_WID=$(tmux list-windows -F '#{window_name}|#{window_id}' \
| awk -F'|' '$1 ~ /^(lvim|nvim)/ { print $2; exit }')
if [ -n "$EDITOR_WID" ]; then
tmux select-window -t "$EDITOR_WID"
exit 0
fi
# No editor window — open lvim in current pane's cwd
PANE_PATH=$(tmux display-message -p '#{pane_current_path}')
tmux new-window -n lvim -c "$PANE_PATH" lvimmapped via .tmux.conf: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
require("sidekick.cli").toggle()focus external tmux sessions when there is no embedded Neovim terminal.Validation
stylua lua/sidekick/cli/init.lua lua/sidekick/cli/session/tmux.luagit diff --check./scripts/testEdit
Probably very related to: #298