Skip to content

Commit a8f20b3

Browse files
committed
Fix copyline for tmux 2.4
With the current implementation, if your shell is : $ echo 'foo' your cursor is at the end of the line, it will copy `$ echo 'foo'` on tmux 2.4, and `echo 'foo'` on tmux 2.3 and below. This normalizes the behavior on both versions so that only `echo 'foo'` is copied
1 parent 15b9980 commit a8f20b3

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

scripts/copy_line.sh

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ enter_tmux_copy_mode() {
3838

3939
start_tmux_selection() {
4040
if tmux_is_at_least 2.4; then
41-
echo "$TMUX_COPY_MODE" >> /tmp/tmux
4241
tmux send -X begin-selection
4342
elif [ "$TMUX_COPY_MODE" == "vi" ]; then
4443
# vi copy mode
@@ -94,19 +93,13 @@ go_to_the_end_of_current_line() {
9493
}
9594

9695
yank_current_line() {
97-
if tmux_is_at_least 2.4; then
98-
enter_tmux_copy_mode
99-
tmux send -X select-line
100-
yank_to_clipboard
101-
else
102-
go_to_the_beginning_of_current_line
103-
add_sleep_for_remote_shells
104-
enter_tmux_copy_mode
105-
start_tmux_selection
106-
end_of_line_in_copy_mode
107-
yank_to_clipboard
108-
go_to_the_end_of_current_line
109-
fi
96+
go_to_the_beginning_of_current_line
97+
add_sleep_for_remote_shells
98+
enter_tmux_copy_mode
99+
start_tmux_selection
100+
end_of_line_in_copy_mode
101+
yank_to_clipboard
102+
go_to_the_end_of_current_line
110103
display_message 'Line copied to clipboard!'
111104
}
112105

0 commit comments

Comments
 (0)