Skip to content

Commit c80003e

Browse files
authored
Merge pull request #2 from surajp/zsh-support
Fix issue with flags when a switch value is enclosed in quotes
2 parents 92162d4 + 4d5090a commit c80003e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

fzf-key-bindings.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ __fzf_sfdx_flags__(){
6363
local selected="$1"
6464
local fullcmd=""
6565
for i in "${@:2}"
66-
do fullcmd+=" $i"
66+
do fullcmd+=" ${i//\"/\\\\\\\"}" #we have to triple escape the double quotes here as it will be used within double quotes again in the command below
6767
done
6868
local ret=`cat ~/.sfdxcommands.json | jq -r ".[] | select(.id==\"$selected\") | .flags | keys[]" | $(__fzfcmd) -m --bind 'ctrl-z:ignore,alt-j:preview-down,alt-k:preview-up' --preview='cat ~/.sfdxcommands.json | jq -r ".[] | select(.id==\"'$selected'\") | .flags | to_entries[] | select (.key==\""{}"\") | [\"Command:\n'"$fullcmd"'\n\",\"Flag Description:\",.value][]"' --preview-window='right:wrap'`
6969
echo "${ret//$'\n'/ --}"

fzf-key-bindings.zsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ __fzf_sfdx_flags(){
113113
local selected="$1"
114114
local fullcmd=""
115115
for i in "${@:2}"
116-
do fullcmd+=" $i"
116+
do fullcmd+=" ${i//\"/\\\\\\\"}" #we have to triple escape the double quotes here as it will be used within double quotes again in the command below
117117
done
118118
local ret=`cat ~/.sfdxcommands.json | jq -r ".[] | select(.id==\"$selected\") | .flags | keys[]" | $(__fzfcmd) -m --bind='ctrl-z:ignore,alt-j:preview-down,alt-k:preview-up' --preview='cat ~/.sfdxcommands.json | jq -r ".[] | select(.id==\"'$selected'\") | .flags | to_entries[] | select (.key==\""{}"\") | [\"Command:\n'"$fullcmd"'\n\",\"Flag Description:\",.value][]"' --preview-window='right:wrap'`
119119
echo "${ret//$'\n'/ --}"

0 commit comments

Comments
 (0)