[shell] make awk regex compatible with macOS default awk (#845)

Unlike GNU awk (gawk), the default awk on macOS does not support \s, making the previous expression not truly equivalent to the original perl command. This change replaces the entire first column with an empty string, achieving the same substitution effect in a portable way.

refs https://github.com/junegunn/fzf/pull/2906
This commit is contained in:
peccu 2025-08-24 06:49:50 +09:00 committed by GitHub
parent 96b25952a4
commit 59f4f48395
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -133,7 +133,7 @@ bindkey '\ec' skim-cd-widget
skim-history-widget() {
local selected num
setopt localoptions noglobsubst noposixbuiltins pipefail no_aliases 2> /dev/null
local awk_filter='{ cmd=$0; sub(/^\s*[0-9]+\**\s+/, "", cmd); if (!seen[cmd]++) print $0 }' # filter out duplicates
local awk_filter='{ cmd=$0; sub(/^[ \t]*[0-9]+\**[ \t]+/, "", cmd); if (!seen[cmd]++) print $0 }' # filter out duplicates
local n=2 fc_opts=''
if [[ -o extended_history ]]; then
local today=$(date +%Y-%m-%d)