diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2024-03-13 23:59:34 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-13 23:59:34 +0900 |
commit | e74b1251c0f579335e03b3e7182cd7a9f88dbe37 (patch) | |
tree | 635d9bd3d4be38ca5623b8ce7241c2674c01b532 /install | |
parent | d282a1649d7d953f028306f13d6616958f3fd1f3 (diff) |
Embed shell integration scripts in fzf binary (`--bash` / `--zsh` / `--fish`) (#3675)
This simplifies the distribution, and the users are less likely to have
problems caused by using incompatible scripts and binaries.
# Set up fzf key bindings and fuzzy completion
eval "$(fzf --bash)"
# Set up fzf key bindings and fuzzy completion
eval "$(fzf --zsh)"
# Set up fzf key bindings
fzf --fish | source
Diffstat (limited to 'install')
-rwxr-xr-x | install | 34 |
1 files changed, 20 insertions, 14 deletions
@@ -262,6 +262,12 @@ if [[ ! "\$PATH" == *$fzf_base_esc/bin* ]]; then PATH="\${PATH:+\${PATH}:}$fzf_base/bin" fi +EOF + + if [[ $auto_completion -eq 1 ]] && [[ $key_bindings -eq 1 ]]; then + echo "eval \"\$(fzf --$shell)\"" >> "$src" + else + cat >> "$src" << EOF # Auto-completion # --------------- $fzf_completion @@ -270,6 +276,7 @@ $fzf_completion # ------------ $fzf_key_bindings EOF + fi echo "OK" done @@ -281,18 +288,6 @@ if [[ "$shells" =~ fish ]]; then or set --universal fish_user_paths \$fish_user_paths "$fzf_base"/bin EOF [ $? -eq 0 ] && echo "OK" || echo "Failed" - - mkdir -p "${fish_dir}/functions" - fish_binding="${fish_dir}/functions/fzf_key_bindings.fish" - if [ $key_bindings -ne 0 ]; then - echo -n "Symlink $fish_binding ... " - ln -sf "$fzf_base/shell/key-bindings.fish" \ - "$fish_binding" && echo "OK" || echo "Failed" - else - echo -n "Removing $fish_binding ... " - rm -f "$fish_binding" - echo "OK" - fi fi append_line() { @@ -355,12 +350,23 @@ done if [ $key_bindings -eq 1 ] && [[ "$shells" =~ fish ]]; then bind_file="${fish_dir}/functions/fish_user_key_bindings.fish" if [ ! -e "$bind_file" ]; then + mkdir -p "${fish_dir}/functions" create_file "$bind_file" \ 'function fish_user_key_bindings' \ - ' fzf_key_bindings' \ + ' fzf --fish | source' \ 'end' else - append_line $update_config "fzf_key_bindings" "$bind_file" + echo "Check $bind_file:" + lno=$(\grep -nF "fzf_key_bindings" "$bind_file" | sed 's/:.*//' | tr '\n' ' ') + if [[ -n $lno ]]; then + echo " ** Found 'fzf_key_bindings' in line #$lno" + echo " ** You have to replace the line to 'fzf --fish | source'" + echo + else + echo " - Clear" + echo + append_line $update_config "fzf --fish | source" "$bind_file" + fi fi fi |