[completion] Replace 'tr' with built-in string substitution

This commit is contained in:
Junegunn Choi 2025-01-27 19:19:08 +09:00
parent af7940746f
commit 2bf5fa27be
No known key found for this signature in database
GPG Key ID: 254BC280FEF9C627
2 changed files with 6 additions and 4 deletions

View File

@ -412,7 +412,7 @@ _fzf_proc_completion() {
local transformer
transformer='
if [[ $FZF_KEY =~ ctrl|alt|shift ]] && [[ -n $FZF_NTH ]]; then
nths=( $(tr , " " <<< "$FZF_NTH") )
nths=( ${FZF_NTH//,/ } )
new_nths=()
found=0
for nth in ${nths[@]}; do
@ -423,7 +423,8 @@ _fzf_proc_completion() {
fi
done
[[ $found = 0 ]] && new_nths+=($FZF_CLICK_HEADER_NTH)
new_nths=$(echo ${new_nths[@]} | tr " " ,)
new_nths=${new_nths[*]}
new_nths=${new_nths// /,}
echo "change-nth($new_nths)+change-prompt($new_nths> )"
else
if [[ $FZF_NTH = $FZF_CLICK_HEADER_NTH ]]; then

View File

@ -293,7 +293,7 @@ _fzf_complete_kill() {
local transformer
transformer='
if [[ $FZF_KEY =~ ctrl|alt|shift ]] && [[ -n $FZF_NTH ]]; then
nths=( $(tr , " " <<< "$FZF_NTH") )
nths=( ${FZF_NTH//,/ } )
new_nths=()
found=0
for nth in ${nths[@]}; do
@ -304,7 +304,8 @@ _fzf_complete_kill() {
fi
done
[[ $found = 0 ]] && new_nths+=($FZF_CLICK_HEADER_NTH)
new_nths=$(echo ${new_nths[@]} | tr " " ,)
new_nths=${new_nths[*]}
new_nths=${new_nths// /,}
echo "change-nth($new_nths)+change-prompt($new_nths> )"
else
if [[ $FZF_NTH = $FZF_CLICK_HEADER_NTH ]]; then