-
Notifications
You must be signed in to change notification settings - Fork 2
fix: scope tmux history copy to visible pane #1435
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -10,5 +10,20 @@ alias tmux-branch='git checkout - && tmux source-file ~/.tmux.conf && echo "Swit | |||||
| # Quick access to tmux cheatsheet | ||||||
| alias tmux-help="less ~/dotfiles/tmux-cheatsheet.md" | ||||||
|
|
||||||
| # Copy full tmux pane history (joined lines) to system clipboard | ||||||
| alias tmux-copy-history='tmux capture-pane -p -J -S -999999 | clipboard_copy' | ||||||
| # Copy visible history from the active (or last) pane to the system clipboard | ||||||
| tmux_copy_history() { | ||||||
| local target_pane | ||||||
|
|
||||||
| if [ -n "$TMUX" ]; then | ||||||
| target_pane="$(tmux display-message -p '#{pane_id}')" | ||||||
| else | ||||||
| if ! target_pane="$(tmux display-message -p -F '#{pane_id}' -t '{last}' 2>/dev/null)"; then | ||||||
|
Contributor
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. Quote the variable expansion to prevent word splitting and pathname expansion.
Suggested change
|
||||||
| echo "tmux-copy-history: no tmux session found" >&2 | ||||||
| return 1 | ||||||
| fi | ||||||
| fi | ||||||
|
|
||||||
| # -S -0 captures from the top of the visible pane (respects a recent clear) | ||||||
| tmux capture-pane -p -J -S -0 -t "${target_pane}" | clipboard_copy | ||||||
| } | ||||||
| alias tmux-copy-history='tmux_copy_history' | ||||||
|
Contributor
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. Quote the variable expansion to prevent word splitting and pathname expansion.
Suggested change
|
||||||
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.
Quote the variable expansion to prevent word splitting and pathname expansion.