-
Notifications
You must be signed in to change notification settings - Fork 0
fix(tmux): replace pbcopy with cross-platform clipboard command #1220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ set-option -g automatic-rename-format '#{b:pane_current_path}' | |
| set-window-option -g mode-keys vi | ||
| bind-key -T copy-mode-vi v send-keys -X begin-selection | ||
| bind-key -T copy-mode-vi r send-keys -X rectangle-toggle | ||
| bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'pbcopy' | ||
| bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel '#{@clipboard_cmd}' | ||
|
|
||
| # Open splits and windows in the current folder | ||
| bind u split-window -l 30% -v -c "#{pane_current_path}" | ||
|
|
@@ -37,6 +37,7 @@ set-option -g repeat-time 1000 | |
|
|
||
| # Clipboard | ||
| set -g set-clipboard on | ||
| set -g @clipboard_cmd "command -v pbcopy >/dev/null 2>&1 && pbcopy || { [ -n \"$WAYLAND_DISPLAY\" ] && wl-copy || xclip -selection clipboard; }" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 馃З Analysis chain馃弫 Script executed: #!/bin/bash
set -euo pipefail
rg -nP '^\s*set\s+-g\s+@clipboard_cmd\s+".*\$WAYLAND_DISPLAY.*"$' home-manager/programs/tmux/tmux.conf
# Expected (current state): one match at Line 40
# Expected (after fix): no matchesRepository: shunkakinoki/dotfiles Length of output: 212 馃寪 Web query:
馃挕 Result: No, $ENV vars like $WAYLAND_DISPLAY are not expanded when parsing set -g Citations:
Runtime detection frozen at parse time due to double-quote expansion. Line 40 uses 馃敡 Suggested fix-set -g `@clipboard_cmd` "command -v pbcopy >/dev/null 2>&1 && pbcopy || { [ -n \"$WAYLAND_DISPLAY\" ] && wl-copy || xclip -selection clipboard; }"
+set -g `@clipboard_cmd` 'if command -v pbcopy >/dev/null 2>&1; then pbcopy; elif [ -n "$WAYLAND_DISPLAY" ] && command -v wl-copy >/dev/null 2>&1; then wl-copy; elif [ -n "$DISPLAY" ] && command -v xclip >/dev/null 2>&1; then xclip -selection clipboard; else exit 1; fi'Use single quotes to defer variable expansion until shell execution time, and add command checks for both fallback commands. 馃 Prompt for AI Agents |
||
|
|
||
| # Status bar | ||
| set -g status "on" | ||
|
|
@@ -59,7 +60,7 @@ bind r command-prompt -I "#{window_name}" "rename-window '%%'" | |
| bind R command-prompt -I "#{session_name}" "rename-session '%%'" | ||
|
|
||
| # Copy text on select | ||
| bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "reattach-to-user-namespace pbcopy" | ||
| bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel '#{@clipboard_cmd}' | ||
|
|
||
| # Switch window | ||
| bind , previous-window | ||
|
|
@@ -90,8 +91,8 @@ bind-key "%" split-window -h -c "#{pane_current_path}" | |
| bind-key '"' split-window -v -c "#{pane_current_path}" | ||
|
|
||
| # Yank pane history to clipboard | ||
| bind y run-shell 'tmux capture-pane -pS - | pbcopy && tmux display-message "Full pane history copied to clipboard"' | ||
| bind v run-shell 'tmux capture-pane -p | pbcopy && tmux display-message "Visible pane copied to clipboard"' | ||
| bind y run-shell 'tmux capture-pane -pS - | #{@clipboard_cmd} && tmux display-message "Full pane history copied to clipboard"' | ||
| bind v run-shell 'tmux capture-pane -p | #{@clipboard_cmd} && tmux display-message "Visible pane copied to clipboard"' | ||
|
Comment on lines
+94
to
+95
|
||
|
|
||
| # Pane number indicator | ||
| set -g display-panes-colour colour233 | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The removal of
reattach-to-user-namespacecould cause clipboard issues on some macOS systems where it's required for tmux to access the system pasteboard. The original configuration used it for mouse-drag copying.To ensure compatibility, I recommend updating the
@clipboard_cmdto check forreattach-to-user-namespaceand use it withpbcopyif it's available. This makes your cross-platform solution more robust.