Skip to content
Myr

[bash] Fix extra space issue of dynamic completion with 'nospace'

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Close #1203

authored by Junegunn Choi · committed by Junegunn Choi · parent eb3afc0 · Browse files · 1 file+12 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+12 added−7 removed

  • other:+12 added−7 removed

1 file+12 added−7 removed

modified:shell/completion.bash+12 added-7 removed
36 unmodified lines
37 [ -n "$TMUX_PANE" ] && [ "${FZF_TMUX:-0}" != 0 ] && [ ${LINES:-40} -gt 15 ] &&38 echo "fzf-tmux -d${FZF_TMUX_HEIGHT:-40%}" || echo "fzf"39}4041_fzf_orig_completion_filter() {42 sed 's/^\(.*-F\) *\([^ ]*\).* \([^ ]*\)$/export _fzf_orig_completion_\3="\1 %s \3 #\2";/' |43 awk -F= '{gsub(/[^A-Za-z0-9_= ;]/, "_", $1); print $1"="$2}'41__fzf_orig_completion_filter() {42 sed 's/^\(.*-F\) *\([^ ]*\).* \([^ ]*\)$/export _fzf_orig_completion_\3="\1 %s \3 #\2"; [[ "\1" = *" -o nospace "* ]] \&\& [[ ! "$__fzf_nospace_commands" = *" \3 "* ]] \&\& __fzf_nospace_commands="$__fzf_nospace_commands \3 ";/' |43 awk -F= '{gsub(/[^A-Za-z0-9_= ;]/, "_", $1);}1'44}4546_fzf_opts_completion() {47 local cur prev opts
78 unmodified lines
126 _completion_loader "$@"127 ret=$?128 # _completion_loader may not have updated completion for the command129 if [ "$(complete -p "$cmd")" != "$orig_complete" ]; then130 eval "$(complete | command grep "\-F.* $orig_cmd$" | _fzf_orig_completion_filter)"131 eval "$orig_complete"130 eval "$(complete | command grep " -F.* $orig_cmd$" | __fzf_orig_completion_filter)"131 if [[ "$__fzf_nospace_commands" = *" $orig_cmd "* ]]; then132 eval "${orig_complete/ -F / -o nospace -F }"133 else134 eval "$orig_complete"135 fi136 fi137 return $ret138 fi139}
19 unmodified lines
159 matches=$(eval "$1 $(printf %q "$dir")" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_COMPLETION_OPTS" $fzf $2 -q "$leftover" | while read -r item; do160 printf "%q$3 " "$item"161 done)162 matches=${matches% }163 [[ -z "$3" ]] && [[ "$__fzf_nospace_commands" = *" ${COMP_WORDS[0]} "* ]] && matches="$matches "164 if [ -n "$matches" ]; then165 COMPREPLY=( "$matches" )166 else167 COMPREPLY=( "$cur" )
114 unmodified lines
282 svn tar unzip zip"283x_cmds="kill ssh telnet unset unalias export"284285# Preserve existing completion281eval $(complete |286eval "$(complete |287 sed -E '/-F/!d; / _fzf/d; '"/ ($(echo $d_cmds $a_cmds $x_cmds | sed 's/ /|/g; s/+/\\+/g'))$/"'!d' |283 _fzf_orig_completion_filter)288 __fzf_orig_completion_filter)"289290if type _completion_loader > /dev/null 2>&1; then291 _fzf_completion_loader=1292fi
41 unmodified lines