Skip to content

Commit fd02a01

Browse files
author
Francisco Lopes
committed
Adopt grep -P to improve matches
- Fix support for matching quotes in URLs - Don't match whitespace before file paths - grep -P is needed
1 parent e95528e commit fd02a01

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

copycat.tmux

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ set_default_stored_searches() {
1515
local ip_search="$(get_tmux_option "$copycat_ip_search_option" "$default_ip_search_key")"
1616

1717
if stored_search_not_defined "$url_search"; then
18-
tmux set-option -g "${COPYCAT_VAR_PREFIX}_${url_search}" "(https?://|git@|git://|ssh://|ftp://|file:///)[[:alnum:]?=%/_.:,;~@!#$&()*+-]*"
18+
tmux set-option -g "${COPYCAT_VAR_PREFIX}_${url_search}" "(https?://|git@|git://|ssh://|ftp://|file:///)[\x22\x27[:alnum:]?=%/_.:,;~@!#$&()*+-]*"
1919
fi
2020
if stored_search_not_defined "$file_search"; then
21-
tmux set-option -g "${COPYCAT_VAR_PREFIX}_${file_search}" "(^|^\.|[[:space:]]|[[:space:]]\.|[[:space:]]\.\.|^\.\.)[[:alnum:]~_-]*/[][[:alnum:]_.#$%&+=/@-]*"
21+
tmux set-option -g "${COPYCAT_VAR_PREFIX}_${file_search}" "(^|(?<=[[:space:]]))(\.|\.\.)?[[:alnum:]~_-]*/[][[:alnum:]_.#$%&+=/@-]*"
2222
fi
2323
if stored_search_not_defined "$digit_search"; then
2424
tmux set-option -g "${COPYCAT_VAR_PREFIX}_${digit_search}" "[[:digit:]]+"

scripts/copycat_generate_results.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ reverse_and_create_copycat_file() {
1717
local file=$1
1818
local copycat_file=$2
1919
local grep_pattern=$3
20-
(tac 2>/dev/null || tail -r) < "$file" | grep -oniE "$grep_pattern" > "$copycat_file"
20+
(tac 2>/dev/null || tail -r) < "$file" | grep -oniP "$grep_pattern" > "$copycat_file"
2121
}
2222

2323
delete_old_files() {

0 commit comments

Comments
 (0)