File tree Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Expand file tree Collapse file tree 3 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 1
1
# Changelog
2
2
3
3
### master
4
+ - if installed use ` gawk ` instead of ` awk ` (@metcalfc )
4
5
5
6
### v2.1.0, Jan 01, 2015
6
7
- combine send-keys calls to reduce flickering (@toupeira )
Original file line number Diff line number Diff line change @@ -15,7 +15,7 @@ TMUX_COPY_MODE="$(tmux_copy_mode)"
15
15
16
16
_file_number_of_lines () {
17
17
local file=" $1 "
18
- echo " $( wc -l $file | awk ' {print $1}' ) "
18
+ echo " $( wc -l $file | $AWK_CMD ' {print $1}' ) "
19
19
}
20
20
21
21
_get_result_line () {
@@ -91,7 +91,7 @@ _get_match_line_position() {
91
91
result_line=" $( _escape_backslash " $result_line " ) "
92
92
match=" $( _escape_backslash " $match " ) "
93
93
94
- local index=$( awk -v a=" $result_line " -v b=" $match " ' BEGIN{print index(a,b)}' )
94
+ local index=$( $AWK_CMD -v a=" $result_line " -v b=" $match " ' BEGIN{print index(a,b)}' )
95
95
local zero_index=$(( index - 1 ))
96
96
echo " $zero_index "
97
97
}
@@ -272,7 +272,7 @@ get_new_position_number() {
272
272
273
273
# doing a forward/up jump
274
274
if [ " $NEXT_PREV " == " next" ]; then
275
- local number_of_results=$( wc -l " $copycat_file " | awk ' { print $1 }' )
275
+ local number_of_results=$( wc -l " $copycat_file " | $AWK_CMD ' { print $1 }' )
276
276
if [ " $current_position " -eq " $number_of_results " ]; then
277
277
# position can't go beyond the last result
278
278
new_position=" $current_position "
Original file line number Diff line number Diff line change @@ -9,6 +9,15 @@ tmux_option_prev="@copycat_prev"
9
9
# keeps track of number of panes in copycat mode
10
10
tmux_option_counter=" @copycat_counter"
11
11
12
+ # === awk vs gawk ===
13
+ command_exists () {
14
+ command -v " $@ " > /dev/null 2>&1
15
+ }
16
+ AWK_CMD=' awk'
17
+ if command_exists gawk; then
18
+ AWK_CMD=' gawk'
19
+ fi
20
+
12
21
# === general helpers ===
13
22
14
23
get_tmux_option () {
@@ -145,7 +154,7 @@ copycat_quit_copy_mode_keys() {
145
154
local copy_mode=" $( tmux_copy_mode) -copy"
146
155
tmux list-keys -t " $copy_mode " |
147
156
\g rep " $commands_that_quit_copy_mode " |
148
- awk ' { print $4}' |
157
+ $AWK_CMD ' { print $4}' |
149
158
sort -u |
150
159
xargs echo
151
160
}
You can’t perform that action at this time.
0 commit comments