@@ -114,33 +114,14 @@ _copycat_enter_mode() {
114
114
115
115
# clears selection from a previous match
116
116
_copycat_exit_select_mode () {
117
- if tmux_is_at_least 2.4; then
118
- tmux send-keys -X clear-selection
119
- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
120
- # vi mode
121
- tmux send-keys Escape
122
- else
123
- # emacs mode
124
- tmux send-keys C-g
125
- fi
117
+ tmux send-keys -X clear-selection
126
118
}
127
119
128
120
# "manually" go up in the scrollback for a number of lines
129
121
_copycat_manually_go_up () {
130
122
local line_number=" $1 "
131
- if tmux_is_at_least 2.4; then
132
- tmux send-keys -X -N " $line_number " cursor-up
133
- tmux send-keys -X start-of-line
134
- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
135
- # vi copy mode
136
- tmux send-keys " $line_number " k 0
137
- else
138
- # emacs copy mode
139
- for (( c= 1 ; c<= "$line_number "; c++ )) ; do
140
- tmux send-keys C-p
141
- done
142
- tmux send-keys C-a
143
- fi
123
+ tmux send-keys -X -N " $line_number " cursor-up
124
+ tmux send-keys -X start-of-line
144
125
}
145
126
146
127
_copycat_create_padding_below_result () {
@@ -161,40 +142,17 @@ _copycat_create_padding_below_result() {
161
142
return
162
143
fi
163
144
164
- if tmux_is_at_least 2.4; then
165
- tmux send-keys -X -N " $padding " cursor-down
166
- tmux send-keys -X -N " $padding " cursor-up
167
- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
168
- # vi copy mode
169
- tmux send-keys " $padding " j " $padding " k
170
- else
171
- # emacs copy mode
172
- for (( c= 1 ; c<= "$padding "; c++ )) ; do
173
- tmux send-keys C-n
174
- done
175
- for (( c= 1 ; c<= "$padding "; c++ )) ; do
176
- tmux send-keys C-p
177
- done
178
- fi
145
+ tmux send-keys -X -N " $padding " cursor-down
146
+ tmux send-keys -X -N " $padding " cursor-up
179
147
}
180
148
181
149
# performs a jump to go to line
182
150
_copycat_go_to_line_with_jump () {
183
151
local line_number=" $1 "
184
152
# first jumps to the "bottom" in copy mode so that jumps are consistent
185
- if tmux_is_at_least 2.4; then
186
- tmux send-keys -X history-bottom
187
- tmux send-keys -X start-of-line
188
- tmux send-keys -X goto-line $line_number
189
- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
190
- # vi copy mode
191
- tmux send-keys G 0 :
192
- tmux send-keys " $line_number " C-m
193
- else
194
- # emacs copy mode
195
- tmux send-keys " M->" C-a g
196
- tmux send-keys " $line_number " C-m
197
- fi
153
+ tmux send-keys -X history-bottom
154
+ tmux send-keys -X start-of-line
155
+ tmux send-keys -X goto-line $line_number
198
156
}
199
157
200
158
# maximum line number that can be reached via tmux 'jump'
@@ -247,40 +205,16 @@ _copycat_position_to_match_start() {
247
205
local match_line_position=" $1 "
248
206
[ " $match_line_position " -eq " 0" ] && return 0
249
207
250
- if tmux_is_at_least 2.4; then
251
- tmux send-keys -X -N " $match_line_position " cursor-right
252
- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
253
- # vi copy mode
254
- tmux send-keys " $match_line_position " l
255
- else
256
- # emacs copy mode
257
- # emacs doesn't have repeat, so we're manually looping :(
258
- for (( c= 1 ; c<= "$match_line_position "; c++ )) ; do
259
- tmux send-keys C-f
260
- done
261
- fi
208
+ tmux send-keys -X -N " $match_line_position " cursor-right
262
209
}
263
210
264
211
_copycat_select () {
265
212
local match=" $1 "
266
213
local length=" ${# match} "
267
- if tmux_is_at_least 2.4; then
268
- tmux send-keys -X begin-selection
269
- tmux send-keys -X -N " $length " cursor-right
270
- if [ " $TMUX_COPY_MODE " == " vi" ]; then
271
- tmux send-keys -X cursor-left # selection correction for 1 char
272
- fi
273
- elif [ " $TMUX_COPY_MODE " == " vi" ]; then
274
- # vi copy mode
275
- tmux send-keys Space " $length " l h # selection correction for 1 char
276
- else
277
- # emacs copy mode
278
- tmux send-keys C-Space
279
- # emacs doesn't have repeat, so we're manually looping :(
280
- for (( c= 1 ; c<= "$length "; c++ )) ; do
281
- tmux send-keys C-f
282
- done
283
- # NO selection correction for emacs mode
214
+ tmux send-keys -X begin-selection
215
+ tmux send-keys -X -N " $length " cursor-right
216
+ if [ " $TMUX_COPY_MODE " == " vi" ]; then
217
+ tmux send-keys -X cursor-left # selection correction for 1 char
284
218
fi
285
219
}
286
220
0 commit comments