Apply shfmt to bash script files (make fmt)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Junegunn Choi · committed by Junegunn Choi · parent f0c4ee4 · Browse files · 11 files·+207 added−203 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
11 files+207 added−203 removed
- other:+207 added−203 removed
Provenance
- Commit
e8cb315- Tree
115b545- Author
Junegunn Choi <junegunn.c@gmail.com>- Committer
Junegunn Choi <junegunn.c@gmail.com>- Parent
f0c4ee4
11 files changed+207 added−203 removed
modified:bin/fzf-preview.sh+2 added-2 removed
47 unmodified lines4849505152525354545556575828 unmodified lines47 unmodified lines exitfi
dim=${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}if [[ $dim = x ]]; thenif [[ $dim == x ]]; then dim=$(stty size < /dev/tty | awk '{print $2 "x" $1}')elif ! [[ $KITTY_WINDOW_ID ]] && (( FZF_PREVIEW_TOP + FZF_PREVIEW_LINES == $(stty size < /dev/tty | awk '{print $1}') )); thenelif ! [[ $KITTY_WINDOW_ID ]] && ((FZF_PREVIEW_TOP + FZF_PREVIEW_LINES == $(stty size < /dev/tty | awk '{print $1}'))); then # Avoid scrolling issue when the Sixel image touches the bottom of the screen # * https://github.com/junegunn/fzf/issues/2544 dim=${FZF_PREVIEW_COLUMNS}x$((FZF_PREVIEW_LINES - 1))fi28 unmodified linesmodified:bin/fzf-tmux+43 added-40 removed
6 unmodified lines7 exit 28 }9 10 fzf="$(command which fzf)" || fzf="$(dirname "$0")/fzf"11-[[ -x "$fzf" ]] || fail 'fzf executable not found'11+[[ -x $fzf ]] || fail 'fzf executable not found'12 13 args=()14 opt=""15 skip=""16 swap=""17 close=""18 term=""19-[[ -n "$LINES" ]] && lines=$LINES || lines=$(tput lines) || lines=$(tmux display-message -p "#{pane_height}")20-[[ -n "$COLUMNS" ]] && columns=$COLUMNS || columns=$(tput cols) || columns=$(tmux display-message -p "#{pane_width}")19+[[ -n $LINES ]] && lines=$LINES || lines=$(tput lines) || lines=$(tmux display-message -p "#{pane_height}")20+[[ -n $COLUMNS ]] && columns=$COLUMNS || columns=$(tput cols) || columns=$(tmux display-message -p "#{pane_width}")21 22 tmux_version=$(tmux -V | sed 's/[^0-9.]//g')23 tmux_32=$(awk '{print ($1 >= 3.2)}' <<< "$tmux_version" 2> /dev/null || bc -l <<< "$tmux_version >= 3.2")24 21 unmodified lines46 47 while [[ $# -gt 0 ]]; do48 arg="$1"49 shift50- [[ -z "$skip" ]] && case "$arg" in50+ [[ -z $skip ]] && case "$arg" in51 -)52 term=153 ;;54 --help)2 unmodified lines57 --version)58 echo "fzf-tmux (with fzf $("$fzf" --version))"59 exit60 ;;61- -p*|-w*|-h*|-x*|-y*|-d*|-u*|-r*|-l*)62- if [[ "$arg" =~ ^-[pwhxy] ]]; then63- [[ "$opt" =~ "-E" ]] || opt="-E"64- elif [[ "$arg" =~ ^.[lr] ]]; then61+ -p* | -w* | -h* | -x* | -y* | -d* | -u* | -r* | -l*)62+ if [[ $arg =~ ^-[pwhxy] ]]; then63+ [[ $opt =~ "-E" ]] || opt="-E"64+ elif [[ $arg =~ ^.[lr] ]]; then65 opt="-h"66- if [[ "$arg" =~ ^.l ]]; then66+ if [[ $arg =~ ^.l ]]; then67 opt="$opt -d"68 swap="; swap-pane -D ; select-pane -L"69 close="; tmux swap-pane -D"70 fi71 else72 opt=""73- if [[ "$arg" =~ ^.u ]]; then73+ if [[ $arg =~ ^.u ]]; then74 opt="$opt -d"75 swap="; swap-pane -D ; select-pane -U"76 close="; tmux swap-pane -D"77 fi78 fi79 if [[ ${#arg} -gt 2 ]]; then80 size="${arg:2}"81 else82- if [[ "$1" =~ ^[0-9%,]+$ ]] || [[ "$1" =~ ^[A-Z]$ ]]; then82+ if [[ $1 =~ ^[0-9%,]+$ ]] || [[ $1 =~ ^[A-Z]$ ]]; then83 size="$1"84 shift85 else86 continue87 fi88 fi89 90- if [[ "$arg" =~ ^-p ]]; then91- if [[ -n "$size" ]]; then90+ if [[ $arg =~ ^-p ]]; then91+ if [[ -n $size ]]; then92 w=${size%%,*}93 h=${size##*,}94 opt="$opt -w$w -h$h"95 fi96- elif [[ "$arg" =~ ^-[whxy] ]]; then96+ elif [[ $arg =~ ^-[whxy] ]]; then97 opt="$opt ${arg:0:2}$size"98- elif [[ "$size" =~ %$ ]]; then99- size=${size:0:((${#size}-1))}100- if [[ $tmux_32 = 1 ]]; then101- if [[ -n "$swap" ]]; then102- opt="$opt -l $(( 100 - size ))%"98+ elif [[ $size =~ %$ ]]; then99+ size=${size:0:${#size}-1}100+ if [[ $tmux_32 == 1 ]]; then101+ if [[ -n $swap ]]; then102+ opt="$opt -l $((100 - size))%"103 else104 opt="$opt -l $size%"105 fi106 else107- if [[ -n "$swap" ]]; then108- opt="$opt -p $(( 100 - size ))"107+ if [[ -n $swap ]]; then108+ opt="$opt -p $((100 - size))"109 else110 opt="$opt -p $size"111 fi112 fi113 else114- if [[ -n "$swap" ]]; then115- if [[ "$arg" =~ ^.l ]]; then114+ if [[ -n $swap ]]; then115+ if [[ $arg =~ ^.l ]]; then116 max=$columns117 else118 max=$lines119 fi120- size=$(( max - size ))120+ size=$((max - size))121 [[ $size -lt 0 ]] && size=0122 opt="$opt -l $size"123 else124 opt="$opt -l $size"9 unmodified lines134 *)135 args+=("$arg")136 ;;137 esac138- [[ -n "$skip" ]] && args+=("$arg")138+ [[ -n $skip ]] && args+=("$arg")139 done140 141-if [[ -z "$TMUX" ]]; then141+if [[ -z $TMUX ]]; then142 "$fzf" "${args[@]}"143 exit $?144 fi145 2 unmodified lines148 # * fzf-tmux script is not compatible with --tmux option in fzf 0.53.0 or later149 args=("${args[@]}" "--no-height" "--bind=ctrl-z:ignore" "--no-tmux")150 151 # Handle zoomed tmux pane without popup options by moving it to a temp window152-if [[ ! "$opt" =~ "-E" ]] && tmux list-panes -F '#F' | grep -q Z; then152+if [[ ! $opt =~ "-E" ]] && tmux list-panes -F '#F' | grep -q Z; then153 zoomed_without_popup=1154 original_window=$(tmux display-message -p "#{window_id}")155 tmp_window=$(tmux new-window -d -P -F "#{window_id}" "bash -c 'while :; do for c in \\| / - '\\;' do sleep 0.2; printf \"\\r\$c fzf-tmux is running\\r\"; done; done'")156 tmux swap-pane -t $tmp_window \; select-window -t $tmp_window7 unmodified lines164 fifo1="${TMPDIR:-/tmp}/fzf-fifo1-$id"165 fifo2="${TMPDIR:-/tmp}/fzf-fifo2-$id"166 fifo3="${TMPDIR:-/tmp}/fzf-fifo3-$id"167 if tmux_win_opts=$(tmux show-options -p remain-on-exit \; show-options -p synchronize-panes 2> /dev/null); then168- tmux_win_opts=( $(sed '/ off/d; s/synchronize-panes/set-option -p synchronize-panes/; s/remain-on-exit/set-option -p remain-on-exit/; s/$/ \\;/' <<< "$tmux_win_opts") )168+ tmux_win_opts=($(sed '/ off/d; s/synchronize-panes/set-option -p synchronize-panes/; s/remain-on-exit/set-option -p remain-on-exit/; s/$/ \\;/' <<< "$tmux_win_opts"))169 tmux_off_opts='; set-option -p synchronize-panes off ; set-option -p remain-on-exit off'170 else171- tmux_win_opts=( $(tmux show-window-options remain-on-exit \; show-window-options synchronize-panes | sed '/ off/d; s/^/set-window-option /; s/$/ \\;/') )171+ tmux_win_opts=($(tmux show-window-options remain-on-exit \; show-window-options synchronize-panes | sed '/ off/d; s/^/set-window-option /; s/$/ \\;/'))172 tmux_off_opts='; set-window-option synchronize-panes off ; set-window-option remain-on-exit off'173 fi174 cleanup() {175 \rm -f $argsf $fifo1 $fifo2 $fifo3176 177 # Restore tmux window options178- if [[ "${#tmux_win_opts[@]}" -gt 1 ]]; then178+ if [[ ${#tmux_win_opts[@]} -gt 1 ]]; then179 eval "tmux ${tmux_win_opts[*]}"180 fi181 182 # Remove temp window if we were zoomed without popup options183- if [[ -n "$zoomed_without_popup" ]]; then183+ if [[ -n $zoomed_without_popup ]]; then184 tmux display-message -p "#{window_id}" > /dev/null185 tmux swap-pane -t $original_window \; \186 select-window -t $original_window \; \187 kill-window -t $tmp_window \; \8 unmodified lines196 trap 'cleanup 1' SIGUSR1197 trap 'cleanup' EXIT198 199 envs="export TERM=$TERM "200-if [[ "$opt" =~ "-E" ]]; then201- if [[ $tmux_version = 3.2 ]]; then200+if [[ $opt =~ "-E" ]]; then201+ if [[ $tmux_version == 3.2 ]]; then202 FZF_DEFAULT_OPTS="--margin 0,1 $FZF_DEFAULT_OPTS"203- elif [[ $tmux_32 = 1 ]]; then203+ elif [[ $tmux_32 == 1 ]]; then204 FZF_DEFAULT_OPTS="--border $FZF_DEFAULT_OPTS"205 opt="-B $opt"206 else207 echo "fzf-tmux: tmux 3.2 or above is required for popup mode" >&22 unmodified lines210 fi211 envs="$envs FZF_DEFAULT_COMMAND=$(printf %q "$FZF_DEFAULT_COMMAND")"212 envs="$envs FZF_DEFAULT_OPTS=$(printf %q "$FZF_DEFAULT_OPTS")"213 envs="$envs FZF_DEFAULT_OPTS_FILE=$(printf %q "$FZF_DEFAULT_OPTS_FILE")"214-[[ -n "$RUNEWIDTH_EASTASIAN" ]] && envs="$envs RUNEWIDTH_EASTASIAN=$(printf %q "$RUNEWIDTH_EASTASIAN")"215-[[ -n "$BAT_THEME" ]] && envs="$envs BAT_THEME=$(printf %q "$BAT_THEME")"214+[[ -n $RUNEWIDTH_EASTASIAN ]] && envs="$envs RUNEWIDTH_EASTASIAN=$(printf %q "$RUNEWIDTH_EASTASIAN")"215+[[ -n $BAT_THEME ]] && envs="$envs BAT_THEME=$(printf %q "$BAT_THEME")"216 echo "$envs;" > "$argsf"217 218 # Build arguments to fzf219 opts=$(printf "%q " "${args[@]}")3 unmodified lines223 close="; trap - EXIT SIGINT SIGTERM $close"224 225 export TMUX=$(cut -d , -f 1,2 <<< "$TMUX")226 mkfifo -m o+w $fifo2227-if [[ "$opt" =~ "-E" ]]; then227+if [[ $opt =~ "-E" ]]; then228 cat $fifo2 &229- if [[ -n "$term" ]] || [[ -t 0 ]]; then229+ if [[ -n $term ]] || [[ -t 0 ]]; then230 cat <<< "\"$fzf\" $opts > $fifo2; out=\$? $close; exit \$out" >> $argsf231 else232 mkfifo $fifo1233 cat <<< "\"$fzf\" $opts < $fifo1 > $fifo2; out=\$? $close; exit \$out" >> $argsf4 unmodified lines238 exit $?239 fi240 241 mkfifo -m o+w $fifo3242-if [[ -n "$term" ]] || [[ -t 0 ]]; then242+if [[ -n $term ]] || [[ -t 0 ]]; then243 cat <<< "\"$fzf\" $opts > $fifo2; echo \$? > $fifo3 $close" >> $argsf244 else245 mkfifo $fifo1246 cat <<< "\"$fzf\" $opts < $fifo1 > $fifo2; echo \$? > $fifo3 $close" >> $argsf1 unmodified line248 fi249 tmux \250 split-window -c "$PWD" $opt "bash -c 'exec -a fzf bash $argsf'" $swap \251 $tmux_off_opts \252- > /dev/null 2>&1 || { "$fzf" "${args[@]}"; exit $?; }252+ > /dev/null 2>&1 || {253+ "$fzf" "${args[@]}"254+ exit $?255+}256 cat $fifo2257 exit "$(cat $fifo3)"modified:shell/common.sh+2 added-3 removed
1123415 unmodified lines202122232524252627283029303132334 unmodified lines
__fzf_defaults() { # $1: Prepend to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS # $2: Append to FZF_DEFAULT_OPTS_FILE and FZF_DEFAULT_OPTS printf '%s\n' "--height ${FZF_TMUX_HEIGHT:-40%} --min-height 20+ --bind=ctrl-z:ignore $1"15 unmodified lines # lacks many features of POSIX awk, so it is essentially useless in the # modern point of view. To use a standard-conforming version in Solaris, # one needs to explicitly use /usr/xpg4/bin/awk. __fzf_awk=/usr/xpg4/bin/awk elif command -v mawk >/dev/null 2>&1; then elif command -v mawk > /dev/null 2>&1; then # choose the faster mawk if: it's installed && build date >= 20230322 && # version >= 1.3.4 local n x y z d IFS=' .' read -r n x y z d <<< $(command mawk -W version 2> /dev/null) [[ $n == mawk ]] && (( d >= 20230302 && (x * 1000 + y) * 1000 + z >= 1003004 )) && __fzf_awk=mawk [[ $n == mawk ]] && ((d >= 20230302 && (x * 1000 + y) * 1000 + z >= 1003004)) && __fzf_awk=mawk fi fi # Note: macOS awk has a quirk that it stops processing at all when it sees # any data not following UTF-8 in the input stream when the current LC_CTYPE4 unmodified linesmodified:shell/completion.bash+73 added-72 removed
46 unmodified lines47 if [[ -z ${__fzf_awk-} ]]; then48 __fzf_awk=awk49 if [[ $OSTYPE == solaris* && -x /usr/xpg4/bin/awk ]]; then50 __fzf_awk=/usr/xpg4/bin/awk51- elif command -v mawk >/dev/null 2>&1; then51+ elif command -v mawk > /dev/null 2>&1; then52 local n x y z d53 IFS=' .' read -r n x y z d <<< $(command mawk -W version 2> /dev/null)54- [[ $n == mawk ]] && (( d >= 20230302 && (x * 1000 + y) * 1000 + z >= 1003004 )) && __fzf_awk=mawk54+ [[ $n == mawk ]] && ((d >= 20230302 && (x * 1000 + y) * 1000 + z >= 1003004)) && __fzf_awk=mawk55 fi56 fi57 LC_ALL=C exec "$__fzf_awk" "$@"58 }59 #----END INCLUDE60 61 __fzf_comprun() {62- if [[ "$(type -t _fzf_comprun 2>&1)" = function ]]; then62+ if [[ "$(type -t _fzf_comprun 2>&1)" == function ]]; then63 _fzf_comprun "$@"64- elif [[ -n "${TMUX_PANE-}" ]] && { [[ "${FZF_TMUX:-0}" != 0 ]] || [[ -n "${FZF_TMUX_OPTS-}" ]]; }; then64+ elif [[ -n ${TMUX_PANE-} ]] && { [[ ${FZF_TMUX:-0} != 0 ]] || [[ -n ${FZF_TMUX_OPTS-} ]]; }; then65 shift66 fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- "$@"67 else68 shift3 unmodified lines72 73 __fzf_orig_completion() {74 local l comp f cmd75 while read -r l; do76- if [[ "$l" =~ ^(.*\ -F)\ *([^ ]*).*\ ([^ ]*)$ ]]; then76+ if [[ $l =~ ^(.*\ -F)\ *([^ ]*).*\ ([^ ]*)$ ]]; then77 comp="${BASH_REMATCH[1]}"78 f="${BASH_REMATCH[2]}"79 cmd="${BASH_REMATCH[3]}"80- [[ "$f" = _fzf_* ]] && continue80+ [[ $f == _fzf_* ]] && continue81 printf -v "_fzf_orig_completion_${cmd//[^A-Za-z0-9_]/_}" "%s" "${comp} %s ${cmd} #${f}"82- if [[ "$l" = *" -o nospace "* ]] && [[ ! "${__fzf_nospace_commands-}" = *" $cmd "* ]]; then82+ if [[ $l == *" -o nospace "* ]] && [[ ${__fzf_nospace_commands-} != *" $cmd "* ]]; then83 __fzf_nospace_commands="${__fzf_nospace_commands-} $cmd "84 fi85 fi86 done27 unmodified lines114 _fzf_opts_completion() {115 local cur prev opts116 COMPREPLY=()117 cur="${COMP_WORDS[COMP_CWORD]}"118- prev="${COMP_WORDS[COMP_CWORD-1]}"118+ prev="${COMP_WORDS[COMP_CWORD - 1]}"119 opts="120 +c --no-color121 +i --no-ignore-case122 +s --no-sort74 unmodified lines197 -q --query198 --"199 200 case "${prev}" in201- --scheme)202- COMPREPLY=( $(compgen -W "default path history" -- "$cur") )203- return 0204- ;;205- --tiebreak)206- COMPREPLY=( $(compgen -W "length chunk begin end index" -- "$cur") )207- return 0208- ;;209- --color)210- COMPREPLY=( $(compgen -W "dark light 16 bw no" -- "$cur") )211- return 0212- ;;213- --layout)214- COMPREPLY=( $(compgen -W "default reverse reverse-list" -- "$cur") )215- return 0216- ;;217- --info)218- COMPREPLY=( $(compgen -W "default right hidden inline inline-right" -- "$cur") )219- return 0220- ;;221- --preview-window)222- COMPREPLY=( $(compgen -W "201+ --scheme)202+ COMPREPLY=($(compgen -W "default path history" -- "$cur"))203+ return 0204+ ;;205+ --tiebreak)206+ COMPREPLY=($(compgen -W "length chunk begin end index" -- "$cur"))207+ return 0208+ ;;209+ --color)210+ COMPREPLY=($(compgen -W "dark light 16 bw no" -- "$cur"))211+ return 0212+ ;;213+ --layout)214+ COMPREPLY=($(compgen -W "default reverse reverse-list" -- "$cur"))215+ return 0216+ ;;217+ --info)218+ COMPREPLY=($(compgen -W "default right hidden inline inline-right" -- "$cur"))219+ return 0220+ ;;221+ --preview-window)222+ COMPREPLY=($(compgen -W "223 default224 hidden225 nohidden226 wrap17 unmodified lines244 border-down border-bottom245 border-left246 border-right247 follow248- nofollow" -- "$cur") )249- return 0250- ;;251- --border)252- COMPREPLY=( $(compgen -W "rounded sharp bold block thinblock double horizontal vertical top bottom left right none" -- "$cur") )253- return 0254- ;;255- --border-label-pos|--preview-label-pos)256- COMPREPLY=( $(compgen -W "center bottom top" -- "$cur") )257- return 0258- ;;248+ nofollow" -- "$cur"))249+ return 0250+ ;;251+ --border)252+ COMPREPLY=($(compgen -W "rounded sharp bold block thinblock double horizontal vertical top bottom left right none" -- "$cur"))253+ return 0254+ ;;255+ --border-label-pos | --preview-label-pos)256+ COMPREPLY=($(compgen -W "center bottom top" -- "$cur"))257+ return 0258+ ;;259 esac260 261- if [[ "$cur" =~ ^-|\+ ]]; then262- COMPREPLY=( $(compgen -W "${opts}" -- "$cur") )261+ if [[ $cur =~ ^-|\+ ]]; then262+ COMPREPLY=($(compgen -W "${opts}" -- "$cur"))263 return 0264 fi265 266 return 05 unmodified lines272 shift273 orig_cmd="$1"274 if __fzf_orig_completion_get_orig_func "$cmd"; then275 "$REPLY" "$@"276- elif [[ -n "${_fzf_completion_loader-}" ]]; then276+ elif [[ -n ${_fzf_completion_loader-} ]]; then277 orig_complete=$(complete -p "$orig_cmd" 2> /dev/null)278 $_fzf_completion_loader "$@"279 ret=$?280 # _completion_loader may not have updated completion for the command5 unmodified lines286 [[ $orig_complete =~ ' -F '(_fzf_[^ ]+)' ' ]] &&287 __fzf_orig_completion_instantiate "$cmd" "${BASH_REMATCH[1]}" &&288 orig_complete=$REPLY289 290- if [[ "${__fzf_nospace_commands-}" = *" $orig_cmd "* ]]; then290+ if [[ ${__fzf_nospace_commands-} == *" $orig_cmd "* ]]; then291 eval "${orig_complete/ -F / -o nospace -F }"292 else293 eval "$orig_complete"294 fi11 unmodified lines306 fi307 COMPREPLY=()308 trigger=${FZF_COMPLETION_TRIGGER-'**'}309 [[ $COMP_CWORD -ge 0 ]] && cur="${COMP_WORDS[COMP_CWORD]}"310- if [[ "$cur" == *"$trigger" ]] && [[ $cur != *'$('* ]] && [[ $cur != *':='* ]] && [[ $cur != *'`'* ]]; then310+ if [[ $cur == *"$trigger" ]] && [[ $cur != *'$('* ]] && [[ $cur != *':='* ]] && [[ $cur != *'`'* ]]; then311 base=${cur:0:${#cur}-${#trigger}}312 eval "base=$base" 2> /dev/null || return313 314 dir=315- [[ $base = *"/"* ]] && dir="$base"315+ [[ $base == *"/"* ]] && dir="$base"316 while true; do317- if [[ -z "$dir" ]] || [[ -d "$dir" ]]; then318- leftover=${base/#"$dir"}319- leftover=${leftover/#\/}320- [[ -z "$dir" ]] && dir='.'321- [[ "$dir" != "/" ]] && dir="${dir/%\//}"317+ if [[ -z $dir ]] || [[ -d $dir ]]; then318+ leftover=${base/#"$dir"/}319+ leftover=${leftover/#\//}320+ [[ -z $dir ]] && dir='.'321+ [[ $dir != "/" ]] && dir="${dir/%\//}"322 matches=$(323 export FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse --scheme=path" "${FZF_COMPLETION_OPTS-} $2")324 unset FZF_DEFAULT_COMMAND FZF_DEFAULT_OPTS_FILE325 if declare -F "$1" > /dev/null; then11 unmodified lines337 printf "%q " "${item%$3}$3"338 done339 )340 matches=${matches% }341- [[ -z "$3" ]] && [[ "${__fzf_nospace_commands-}" = *" ${COMP_WORDS[0]} "* ]] && matches="$matches "342- if [[ -n "$matches" ]]; then343- COMPREPLY=( "$matches" )341+ [[ -z $3 ]] && [[ ${__fzf_nospace_commands-} == *" ${COMP_WORDS[0]} "* ]] && matches="$matches "342+ if [[ -n $matches ]]; then343+ COMPREPLY=("$matches")344 else345- COMPREPLY=( "$cur" )345+ COMPREPLY=("$cur")346 fi347 # To redraw line after fzf closes (printf '\e[5n')348 bind '"\e[0n": redraw-current-line' 2> /dev/null349 printf '\e[5n'350 return 0351 fi352 dir=$(command dirname "$dir")353- [[ "$dir" =~ /$ ]] || dir="$dir"/353+ [[ $dir =~ /$ ]] || dir="$dir"/354 done355 else356 shift357 shift7 unmodified lines365 local args rest str_arg i sep366 args=("$@")367 sep=368 for i in "${!args[@]}"; do369- if [[ "${args[$i]}" = -- ]]; then369+ if [[ ${args[$i]} == -- ]]; then370 sep=$i371 break372 fi373 done374- if [[ -n "$sep" ]]; then374+ if [[ -n $sep ]]; then375 str_arg=376 rest=("${args[@]:$((sep + 1)):${#args[@]}}")377- args=("${args[@]:0:$sep}")377+ args=("${args[@]:0:sep}")378 else379 str_arg=$1380 args=()381 shift6 unmodified lines388 389 trigger=${FZF_COMPLETION_TRIGGER-'**'}390 cmd="${COMP_WORDS[0]}"391 cur="${COMP_WORDS[COMP_CWORD]}"392- if [[ "$cur" == *"$trigger" ]] && [[ $cur != *'$('* ]] && [[ $cur != *':='* ]] && [[ $cur != *'`'* ]]; then392+ if [[ $cur == *"$trigger" ]] && [[ $cur != *'$('* ]] && [[ $cur != *':='* ]] && [[ $cur != *'`'* ]]; then393 cur=${cur:0:${#cur}-${#trigger}}394 395 selected=$(396 FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse" "${FZF_COMPLETION_OPTS-} $str_arg") \397 FZF_DEFAULT_OPTS_FILE='' \398- __fzf_comprun "${rest[0]}" "${args[@]}" -q "$cur" | eval "$post" | command tr '\n' ' ')398+ __fzf_comprun "${rest[0]}" "${args[@]}" -q "$cur" | eval "$post" | command tr '\n' ' '399+ )400 selected=${selected% } # Strip trailing space not to repeat "-o nospace"400- if [[ -n "$selected" ]]; then401+ if [[ -n $selected ]]; then402 COMPREPLY=("$selected")403 else404 COMPREPLY=("$cur")405 fi49 unmodified lines455 fi456 '457 _fzf_complete -m --header-lines=1 --no-preview --wrap --color fg:dim,nth:regular \458 --bind "click-header:transform:$transformer" -- "$@" < <(458- command ps -eo user,pid,ppid,start,time,command 2> /dev/null ||459- command ps -eo user,pid,ppid,time,args 2> /dev/null || # For BusyBox460- command ps --everyone --full --windows # For cygwin461- )459+ command ps -eo user,pid,ppid,start,time,command 2> /dev/null ||460+ command ps -eo user,pid,ppid,time,args 2> /dev/null || # For BusyBox461+ command ps --everyone --full --windows # For cygwin462+ )463 }464 465 _fzf_proc_completion_post() {466 __fzf_exec_awk '{print $2}'74 unmodified lines541 # > the second argument ($2) is the word being completed,542 # > and the third argument ($3) is the word preceding the word being completed on the current command line.543 _fzf_complete_ssh() {544 case $3 in544- -i|-F|-E)545+ -i | -F | -E)546 _fzf_path_completion "$@"547 ;;548 *)549 local user=549- [[ "$2" =~ '@' ]] && user="${2%%@*}@"550+ [[ $2 =~ '@' ]] && user="${2%%@*}@"551 _fzf_complete +m -- "$@" < <(__fzf_list_hosts | __fzf_exec_awk -v user="$user" '{print user $0}')552 ;;553 esac554 }122 unmodified lines677 shift678 __fzf_orig_completion < <(complete -p "$@" 2> /dev/null)679 for cmd in "$@"; do680 case "$kind" in680- dir) __fzf_defc "$cmd" "$fn" "-o nospace -o dirnames" ;;681- var) __fzf_defc "$cmd" "$fn" "-o default -o nospace -v" ;;681+ dir) __fzf_defc "$cmd" "$fn" "-o nospace -o dirnames" ;;682+ var) __fzf_defc "$cmd" "$fn" "-o default -o nospace -v" ;;683 alias) __fzf_defc "$cmd" "$fn" "-a" ;;683- *) __fzf_defc "$cmd" "$fn" "-o default -o bashdefault" ;;684+ *) __fzf_defc "$cmd" "$fn" "-o default -o bashdefault" ;;685 esac686 done687 }688 #----END shfmt2 unmodified linesmodified:shell/completion.zsh+2 added-2 removed
110 unmodified lines111 if [[ -z ${__fzf_awk-} ]]; then112 __fzf_awk=awk113 if [[ $OSTYPE == solaris* && -x /usr/xpg4/bin/awk ]]; then114 __fzf_awk=/usr/xpg4/bin/awk115- elif command -v mawk >/dev/null 2>&1; then115+ elif command -v mawk > /dev/null 2>&1; then116 local n x y z d117 IFS=' .' read -r n x y z d <<< $(command mawk -W version 2> /dev/null)118- [[ $n == mawk ]] && (( d >= 20230302 && (x * 1000 + y) * 1000 + z >= 1003004 )) && __fzf_awk=mawk118+ [[ $n == mawk ]] && ((d >= 20230302 && (x * 1000 + y) * 1000 + z >= 1003004)) && __fzf_awk=mawk119 fi120 fi121 LC_ALL=C exec "$__fzf_awk" "$@"122 }350 unmodified linesmodified:shell/key-bindings.bash+19 added-19 removed
32 unmodified lines33 if [[ -z ${__fzf_awk-} ]]; then34 __fzf_awk=awk35 if [[ $OSTYPE == solaris* && -x /usr/xpg4/bin/awk ]]; then36 __fzf_awk=/usr/xpg4/bin/awk37- elif command -v mawk >/dev/null 2>&1; then37+ elif command -v mawk > /dev/null 2>&1; then38 local n x y z d39 IFS=' .' read -r n x y z d <<< $(command mawk -W version 2> /dev/null)40- [[ $n == mawk ]] && (( d >= 20230302 && (x * 1000 + y) * 1000 + z >= 1003004 )) && __fzf_awk=mawk40+ [[ $n == mawk ]] && ((d >= 20230302 && (x * 1000 + y) * 1000 + z >= 1003004)) && __fzf_awk=mawk41 fi42 fi43 LC_ALL=C exec "$__fzf_awk" "$@"44 }45 #----END INCLUDE46 47 __fzf_select__() {48 FZF_DEFAULT_COMMAND=${FZF_CTRL_T_COMMAND:-} \49- FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse --walker=file,dir,follow,hidden --scheme=path" "${FZF_CTRL_T_OPTS-} -m") \50- FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) "$@" |49+ FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse --walker=file,dir,follow,hidden --scheme=path" "${FZF_CTRL_T_OPTS-} -m") \50+ FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) "$@" |51 while read -r item; do52- printf '%q ' "$item" # escape special chars52+ printf '%q ' "$item" # escape special chars53 done54 }55 56 __fzfcmd() {57- [[ -n "${TMUX_PANE-}" ]] && { [[ "${FZF_TMUX:-0}" != 0 ]] || [[ -n "${FZF_TMUX_OPTS-}" ]]; } &&57+ [[ -n ${TMUX_PANE-} ]] && { [[ ${FZF_TMUX:-0} != 0 ]] || [[ -n ${FZF_TMUX_OPTS-} ]]; } &&58 echo "fzf-tmux ${FZF_TMUX_OPTS:--d${FZF_TMUX_HEIGHT:-40%}} -- " || echo "fzf"59 }60 61 fzf-file-widget() {62 local selected="$(__fzf_select__ "$@")"63- READLINE_LINE="${READLINE_LINE:0:$READLINE_POINT}$selected${READLINE_LINE:$READLINE_POINT}"64- READLINE_POINT=$(( READLINE_POINT + ${#selected} ))63+ READLINE_LINE="${READLINE_LINE:0:READLINE_POINT}$selected${READLINE_LINE:READLINE_POINT}"64+ READLINE_POINT=$((READLINE_POINT + ${#selected}))65 }66 67 __fzf_cd__() {68 local dir69 dir=$(70 FZF_DEFAULT_COMMAND=${FZF_ALT_C_COMMAND:-} \71- FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse --walker=dir,follow,hidden --scheme=path" "${FZF_ALT_C_OPTS-} +m") \72- FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd)71+ FZF_DEFAULT_OPTS=$(__fzf_defaults "--reverse --walker=dir,follow,hidden --scheme=path" "${FZF_ALT_C_OPTS-} +m") \72+ FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd)73 ) && printf 'builtin cd -- %q' "$(builtin unset CDPATH && builtin cd -- "$dir" && builtin pwd)"74 }75 76 if command -v perl > /dev/null; then7 unmodified lines84 FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"$'\t'"↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} +m --read0") \85 FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) --query "$READLINE_LINE"86 ) || return87 READLINE_LINE=$(command perl -pe 's/^\d*\t//' <<< "$output")88- if [[ -z "$READLINE_POINT" ]]; then88+ if [[ -z $READLINE_POINT ]]; then89 echo "$READLINE_LINE"90 else91 READLINE_POINT=0x7fffffff92 fi93 }94 else # awk - fallback for POSIX systems95 __fzf_history__() {96 local output script97- [[ $(HISTTIMEFORMAT='' builtin history 1) =~ [[:digit:]]+ ]] # how many history entries97+ [[ $(HISTTIMEFORMAT='' builtin history 1) =~ [[:digit:]]+ ]] # how many history entries98 script='function P(b) { ++n; sub(/^[ *]/, "", b); if (!seen[b]++) { printf "%d\t%s%c", '$((BASH_REMATCH + 1))' - n, b, 0 } }99 NR==1 { b = substr($0, 2); next }100 /^\t/ { P(b); b = substr($0, 2); next }101 { b = b RS $0 }102 END { if (NR) P(b) }'103 output=$(104 set +o pipefail105- builtin fc -lnr -2147483648 2> /dev/null | # ( $'\t '<lines>$'\n' )* ; <lines> ::= [^\n]* ( $'\n'<lines> )*106- __fzf_exec_awk "$script" | # ( <counter>$'\t'<lines>$'\000' )*105+ builtin fc -lnr -2147483648 2> /dev/null | # ( $'\t '<lines>$'\n' )* ; <lines> ::= [^\n]* ( $'\n'<lines> )*106+ __fzf_exec_awk "$script" | # ( <counter>$'\t'<lines>$'\000' )*107 FZF_DEFAULT_OPTS=$(__fzf_defaults "" "-n2..,.. --scheme=history --bind=ctrl-r:toggle-sort --wrap-sign '"$'\t'"↳ ' --highlight-line ${FZF_CTRL_R_OPTS-} +m --read0") \108 FZF_DEFAULT_OPTS_FILE='' $(__fzfcmd) --query "$READLINE_LINE"109 ) || return110 READLINE_LINE=${output#*$'\t'}111- if [[ -z "$READLINE_POINT" ]]; then111+ if [[ -z $READLINE_POINT ]]; then112 echo "$READLINE_LINE"113 else114 READLINE_POINT=0x7fffffff115 fi6 unmodified lines122 bind -m vi-command '"\C-z": emacs-editing-mode'123 bind -m vi-insert '"\C-z": emacs-editing-mode'124 bind -m emacs-standard '"\C-z": vi-editing-mode'125 126-if (( BASH_VERSINFO[0] < 4 )); then126+if ((BASH_VERSINFO[0] < 4)); then127 # CTRL-T - Paste the selected file path into the command line128- if [[ "${FZF_CTRL_T_COMMAND-x}" != "" ]]; then128+ if [[ ${FZF_CTRL_T_COMMAND-x} != "" ]]; then129 bind -m emacs-standard '"\C-t": " \C-b\C-k \C-u`__fzf_select__`\e\C-e\er\C-a\C-y\C-h\C-e\e \C-y\ey\C-x\C-x\C-f\C-y\ey\C-_"'130 bind -m vi-command '"\C-t": "\C-z\C-t\C-z"'131 bind -m vi-insert '"\C-t": "\C-z\C-t\C-z"'132 fi3 unmodified lines136 bind -m vi-command '"\C-r": "\C-z\C-r\C-z"'137 bind -m vi-insert '"\C-r": "\C-z\C-r\C-z"'138 else139 # CTRL-T - Paste the selected file path into the command line140- if [[ "${FZF_CTRL_T_COMMAND-x}" != "" ]]; then140+ if [[ ${FZF_CTRL_T_COMMAND-x} != "" ]]; then141 bind -m emacs-standard -x '"\C-t": fzf-file-widget'142 bind -m vi-command -x '"\C-t": fzf-file-widget'143 bind -m vi-insert -x '"\C-t": fzf-file-widget'144 fi4 unmodified lines149 bind -m vi-insert -x '"\C-r": __fzf_history__'150 fi151 152 # ALT-C - cd into the selected directory153-if [[ "${FZF_ALT_C_COMMAND-x}" != "" ]]; then153+if [[ ${FZF_ALT_C_COMMAND-x} != "" ]]; then154 bind -m emacs-standard '"\ec": " \C-b\C-k \C-u`__fzf_cd__`\e\C-e\er\C-m\C-y\C-h\e \C-y\ey\C-x\C-x\C-d\C-y\ey\C-_"'155 bind -m vi-command '"\ec": "\C-z\ec\C-z"'156 bind -m vi-insert '"\ec": "\C-z\ec\C-z"'157 fi3 unmodified linesmodified:shell/key-bindings.zsh+2 added-2 removed
52 unmodified lines53 if [[ -z ${__fzf_awk-} ]]; then54 __fzf_awk=awk55 if [[ $OSTYPE == solaris* && -x /usr/xpg4/bin/awk ]]; then56 __fzf_awk=/usr/xpg4/bin/awk57- elif command -v mawk >/dev/null 2>&1; then57+ elif command -v mawk > /dev/null 2>&1; then58 local n x y z d59 IFS=' .' read -r n x y z d <<< $(command mawk -W version 2> /dev/null)60- [[ $n == mawk ]] && (( d >= 20230302 && (x * 1000 + y) * 1000 + z >= 1003004 )) && __fzf_awk=mawk60+ [[ $n == mawk ]] && ((d >= 20230302 && (x * 1000 + y) * 1000 + z >= 1003004)) && __fzf_awk=mawk61 fi62 fi63 LC_ALL=C exec "$__fzf_awk" "$@"64 }98 unmodified linesmodified:shell/update.sh+2 added-1 removed
7 unmodified lines891011121213141516171819202147 unmodified lines7 unmodified lines
update() { { sed -n '1,/^#----BEGIN INCLUDE common\.sh/p' "$1" cat <<EOF cat << EOF# NOTE: Do not directly edit this section, which is copied from "common.sh".# To modify it, one can edit "common.sh" and run "./update.sh" to apply# the changes. See code comments in "common.sh" for the implementation details.EOF echo grep -v '^[[:blank:]]*#' "$dir/common.sh" # remove code comments in common.sh sed -n '/^#----END INCLUDE/,$p' "$1" } > "$1.part"
47 unmodified linesmodified:.editorconfig+2 added-2 removed
2 unmodified lines3 [*.{sh,bash}]4 indent_style = space5 indent_size = 26 simplify = true7-binary_next_line = true7+binary_next_line = false8 switch_case_indent = true9 space_redirects = true10 function_next_line = false11 1 unmodified line13 [{install,uninstall,bin/fzf-preview.sh,bin/fzf-tmux}]14 indent_style = space15 indent_size = 216 simplify = true17-binary_next_line = true17+binary_next_line = false18 switch_case_indent = true19 space_redirects = true20 function_next_line = falsemodified:install+54 added-54 removed
44 unmodified lines45 prefix='"${XDG_CONFIG_HOME:-$HOME/.config}"/fzf/fzf'46 prefix_expand=${XDG_CONFIG_HOME:-$HOME/.config}/fzf/fzf47 mkdir -p "${XDG_CONFIG_HOME:-$HOME/.config}/fzf"48 ;;49- --key-bindings) key_bindings=1 ;;50- --no-key-bindings) key_bindings=0 ;;51- --completion) auto_completion=1 ;;52- --no-completion) auto_completion=0 ;;53- --update-rc) update_config=1 ;;54- --no-update-rc) update_config=0 ;;55- --bin) ;;56- --no-bash) shells=${shells/bash/} ;;57- --no-zsh) shells=${shells/zsh/} ;;58- --no-fish) shells=${shells/fish/} ;;49+ --key-bindings) key_bindings=1 ;;50+ --no-key-bindings) key_bindings=0 ;;51+ --completion) auto_completion=1 ;;52+ --no-completion) auto_completion=0 ;;53+ --update-rc) update_config=1 ;;54+ --no-update-rc) update_config=0 ;;55+ --bin) ;;56+ --no-bash) shells=${shells/bash/} ;;57+ --no-zsh) shells=${shells/zsh/} ;;58+ --no-fish) shells=${shells/fish/} ;;59 *)60 echo "unknown option: $opt"61 help62 exit 140 unmodified lines103 }104 105 link_fzf_in_path() {106 if which_fzf="$(command -v fzf)"; then107- echo " - Found in \$PATH"107+ echo ' - Found in $PATH'108 echo " - Creating symlink: bin/fzf -> $which_fzf"109 (cd "$fzf_base"/bin && rm -f fzf && ln -sf "$which_fzf" fzf)110 check_binary && return111 fi1 unmodified line113 }114 115 try_curl() {116 command -v curl > /dev/null &&117- if [[ $1 =~ tar.gz$ ]]; then118- curl -fL $1 | tar --no-same-owner -xzf -119- else120- local temp=${TMPDIR:-/tmp}/fzf.zip121- curl -fLo "$temp" $1 && unzip -o "$temp" && rm -f "$temp"122- fi117+ if [[ $1 =~ tar.gz$ ]]; then118+ curl -fL $1 | tar --no-same-owner -xzf -119+ else120+ local temp=${TMPDIR:-/tmp}/fzf.zip121+ curl -fLo "$temp" $1 && unzip -o "$temp" && rm -f "$temp"122+ fi123 }124 125 try_wget() {126 command -v wget > /dev/null &&127- if [[ $1 =~ tar.gz$ ]]; then128- wget -O - $1 | tar --no-same-owner -xzf -129- else130- local temp=${TMPDIR:-/tmp}/fzf.zip131- wget -O "$temp" $1 && unzip -o "$temp" && rm -f "$temp"132- fi127+ if [[ $1 =~ tar.gz$ ]]; then128+ wget -O - $1 | tar --no-same-owner -xzf -129+ else130+ local temp=${TMPDIR:-/tmp}/fzf.zip131+ wget -O "$temp" $1 && unzip -o "$temp" && rm -f "$temp"132+ fi133 }134 135 download() {136 echo "Downloading bin/fzf ..."26 unmodified lines163 chmod +x fzf && check_binary164 }165 166 # Try to download binary executable167-archi=$(uname -smo 2>/dev/null || uname -sm)167+archi=$(uname -smo 2> /dev/null || uname -sm)168 binary_available=1169 binary_error=""170 case "$archi" in171- Darwin\ arm64*) download fzf-$version-darwin_arm64.tar.gz ;;172- Darwin\ x86_64*) download fzf-$version-darwin_amd64.tar.gz ;;173- Linux\ armv5*) download fzf-$version-linux_armv5.tar.gz ;;174- Linux\ armv6*) download fzf-$version-linux_armv6.tar.gz ;;175- Linux\ armv7*) download fzf-$version-linux_armv7.tar.gz ;;176- Linux\ armv8*) download fzf-$version-linux_arm64.tar.gz ;;171+ Darwin\ arm64*) download fzf-$version-darwin_arm64.tar.gz ;;172+ Darwin\ x86_64*) download fzf-$version-darwin_amd64.tar.gz ;;173+ Linux\ armv5*) download fzf-$version-linux_armv5.tar.gz ;;174+ Linux\ armv6*) download fzf-$version-linux_armv6.tar.gz ;;175+ Linux\ armv7*) download fzf-$version-linux_armv7.tar.gz ;;176+ Linux\ armv8*) download fzf-$version-linux_arm64.tar.gz ;;177 Linux\ aarch64\ Android) download fzf-$version-android_arm64.tar.gz ;;178- Linux\ aarch64*) download fzf-$version-linux_arm64.tar.gz ;;179- Linux\ loongarch64*) download fzf-$version-linux_loong64.tar.gz ;;180- Linux\ ppc64le*) download fzf-$version-linux_ppc64le.tar.gz ;;181- Linux\ *64*) download fzf-$version-linux_amd64.tar.gz ;;182- Linux\ s390x*) download fzf-$version-linux_s390x.tar.gz ;;183- FreeBSD\ *64*) download fzf-$version-freebsd_amd64.tar.gz ;;184- OpenBSD\ *64*) download fzf-$version-openbsd_amd64.tar.gz ;;185- CYGWIN*\ *64*) download fzf-$version-windows_amd64.zip ;;186- MINGW*\ *64*) download fzf-$version-windows_amd64.zip ;;187- MSYS*\ *64*) download fzf-$version-windows_amd64.zip ;;188- Windows*\ *64*) download fzf-$version-windows_amd64.zip ;;189- *) binary_available=0 binary_error=1 ;;178+ Linux\ aarch64*) download fzf-$version-linux_arm64.tar.gz ;;179+ Linux\ loongarch64*) download fzf-$version-linux_loong64.tar.gz ;;180+ Linux\ ppc64le*) download fzf-$version-linux_ppc64le.tar.gz ;;181+ Linux\ *64*) download fzf-$version-linux_amd64.tar.gz ;;182+ Linux\ s390x*) download fzf-$version-linux_s390x.tar.gz ;;183+ FreeBSD\ *64*) download fzf-$version-freebsd_amd64.tar.gz ;;184+ OpenBSD\ *64*) download fzf-$version-openbsd_amd64.tar.gz ;;185+ CYGWIN*\ *64*) download fzf-$version-windows_amd64.zip ;;186+ MINGW*\ *64*) download fzf-$version-windows_amd64.zip ;;187+ MSYS*\ *64*) download fzf-$version-windows_amd64.zip ;;188+ Windows*\ *64*) download fzf-$version-windows_amd64.zip ;;189+ *) binary_available=0 binary_error=1 ;;190 esac191 192 cd "$fzf_base"193 if [ -n "$binary_error" ]; then20 unmodified lines214 exit 1215 fi216 fi217 218-[[ "$*" =~ "--bin" ]] && exit 0218+[[ $* =~ "--bin" ]] && exit 0219 220 for s in $shells; do221 if ! command -v "$s" > /dev/null; then222 shells=${shells/$s/}18 unmodified lines241 fi242 243 echo244 for shell in $shells; do245- [[ "$shell" = fish ]] && continue245+ [[ $shell == fish ]] && continue246 src=${prefix_expand}.${shell}247 echo -n "Generate $src ... "248 249 fzf_completion="source \"$fzf_base/shell/completion.${shell}\""15 unmodified lines265 266 EOF267 268 if [[ $auto_completion -eq 1 ]] && [[ $key_bindings -eq 1 ]]; then269- if [[ "$shell" = zsh ]]; then269+ if [[ $shell == zsh ]]; then270 echo "source <(fzf --$shell)" >> "$src"271 else272 echo "eval \"\$(fzf --$shell)\"" >> "$src"273 fi11 unmodified lines285 echo "OK"286 done287 288 # fish289-if [[ "$shells" =~ fish ]]; then289+if [[ $shells =~ fish ]]; then290 echo -n "Update fish_user_paths ... "291 fish << EOF292 echo \$fish_user_paths | \grep "$fzf_base"/bin > /dev/null293 or set --universal fish_user_paths \$fish_user_paths "$fzf_base"/bin23 unmodified lines317 echo " - Already exists:"318 sed 's/^/ Line /' <<< "$lines"319 320 update=0321- if ! \grep -qv "^[0-9]*:[[:space:]]*#" <<< "$lines" ; then321+ if ! \grep -qv "^[0-9]*:[[:space:]]*#" <<< "$lines"; then322 echo " - But they all seem to be commented"323- ask " - Continue modifying $file?"323+ ask " - Continue modifying $file?"324 update=$?325 fi326 fi327 27 unmodified lines355 update_config=$?356 fi357 echo358 for shell in $shells; do359- [[ "$shell" = fish ]] && continue359+ [[ $shell == fish ]] && continue360 [ $shell = zsh ] && dest=${ZDOTDIR:-~}/.zshrc || dest=~/.bashrc361 append_line $update_config "[ -f ${prefix}.${shell} ] && source ${prefix}.${shell}" "$dest" "${prefix}.${shell}"362 done363 364-if [ $key_bindings -eq 1 ] && [[ "$shells" =~ fish ]]; then364+if [ $key_bindings -eq 1 ] && [[ $shells =~ fish ]]; then365 bind_file="${fish_dir}/functions/fish_user_key_bindings.fish"366 if [ ! -e "$bind_file" ]; then367 mkdir -p "${fish_dir}/functions"368 create_file "$bind_file" \16 unmodified lines385 fi386 387 if [ $update_config -eq 1 ]; then388 echo 'Finished. Restart your shell or reload config file.'389- if [[ "$shells" =~ bash ]]; then389+ if [[ $shells =~ bash ]]; then390 echo -n ' source ~/.bashrc # bash'391- [[ "$archi" =~ Darwin ]] && echo -n ' (.bashrc should be loaded from .bash_profile)'391+ [[ $archi =~ Darwin ]] && echo -n ' (.bashrc should be loaded from .bash_profile)'392 echo393 fi394- [[ "$shells" =~ zsh ]] && echo " source ${ZDOTDIR:-~}/.zshrc # zsh"395- [[ "$shells" =~ fish ]] && [ $key_bindings -eq 1 ] && echo ' fzf_key_bindings # fish'394+ [[ $shells =~ zsh ]] && echo " source ${ZDOTDIR:-~}/.zshrc # zsh"395+ [[ $shells =~ fish ]] && [ $key_bindings -eq 1 ] && echo ' fzf_key_bindings # fish'396 echo397 echo 'Use uninstall script to remove fzf.'398 echo399 fi1 unmodified linemodified:uninstall+6 added-6 removed
62 unmodified lines63 shift64 line_no=165 continue66 fi67- line_no=$(( $(sed 's/:.*//' <<< "$line") + line_no - 1 ))67+ line_no=$(($(sed 's/:.*//' <<< "$line") + line_no - 1))68 content=$(sed 's/^[0-9]*://' <<< "$line")69 match=170- echo " - Line #$line_no: $content"70+ echo " - Line #$line_no: $content"71 [ "$content" = "$1" ] || ask " - Remove?"72 if [ $? -eq 0 ]; then73 temp=$(mktemp)74 awk -v n=$line_no 'NR == n {next} {print}' "$src" > "$temp" &&75 cat "$temp" > "$src" && rm -f "$temp" || break76- echo " - Removed"76+ echo " - Removed"77 else78- echo " - Skipped"79- line_no=$(( line_no + 1 ))78+ echo " - Skipped"79+ line_no=$((line_no + 1))80 fi81 done82 [ $match -eq 0 ] && echo " - Nothing found"83 echo24 unmodified lines108 fi109 fi110 111 config_dir=$(dirname "$prefix_expand")112-if [[ "$xdg" = 1 ]] && [[ "$config_dir" = */fzf ]] && [[ -d "$config_dir" ]]; then112+if [[ $xdg == 1 ]] && [[ $config_dir == */fzf ]] && [[ -d $config_dir ]]; then113 rmdir "$config_dir"114 fi