akinomyoga / blesh-contrib

Source of settings for Bash Line Editor https://github.com/akinomyoga/ble.sh (for ble-0.4+)
BSD 3-Clause "New" or "Revised" License
36 stars 10 forks source link

Unclear instructions fzf-integration #10

Closed Darukutsu closed 1 year ago

Darukutsu commented 1 year ago

This is more question if README.MD should be updated.

I probably don't understand something, but provided instructions didn't work for me, instead I had to do something reversely (to work).

Where should I source '.fzf.bash'? Before or after ble.sh.

My working config:

# ~/.bashrc

[[ $- == *i* ]] && source /usr/share/blesh/ble.sh --noattach
# If not running interactively, don't do anything
[[ $- != *i* ]] && return

...
## fzf readline search replacement
## neither of these are working even if if-statement stays as original
#source $XDG_CONFIG_HOME/bash/fzf.bash
#ble-import -d contrib/fzf-key-bindings

[[ ${BLE_VERSION-} ]] && ble-attach

## fzf 
## this works
source $XDG_CONFIG_HOME/bash/fzf.bash
# fzf.bash

# If ble/contrib/fzf cannot find the fzf directory, please set the following
# variable "_ble_contrib_fzf_base" manually.  The value
# "/path/to/fzf-directory" should be replaced by a path to the fzf directory
# such as "$HOME/.fzf" or "/usr/share/fzf" that contain
# "shell/{completion,key-bindings}.bash" or "{completion,key-bindings}.bash".

#_ble_contrib_fzf_base=/usr/share/fzf

# Setup fzf
# ---------
#if [[ ! "$PATH" == *"/usr/bin/fzf"* ]]; then
#  export PATH="${PATH:+${PATH}:}/usr/bin/fzf"
#fi

# Auto-completion
# ---------------
#if [[ $- == *i* ]]; then
#  # Note: If you would like to combine fzf-completion with bash_completion, you
#  # need to load bash_completion earlier than fzf-completion.
#
#  #source /path/to/bash_completion.sh
#
#  if [[ ${BLE_VERSION-} ]]; then
#    ble-import -d contrib/fzf-completion
#  else
#    source /usr/share/fzf/completion.bash 2> /dev/null
#  fi
#fi

# Key bindings
# ------------
if [[ ${BLE_VERSION-} ]]; then
  source /usr/share/fzf/key-bindings.bash
  #source /home/daru/.config/bash/fzf-key-bindings.bash
else
  ble-import contrib/fzf-key-bindings
fi
akinomyoga commented 1 year ago

Where should I source '.fzf.bash'? Before or after ble.sh.

It should be sourced after ble.sh.

Ah, OK. When I initially wrote this contrib/README.md, I think the ble.sh/README.md was telling users to source ble.sh at the beginning of ~/.bashrc. However, now ble.sh/README.md suggests an alternative option to put source ble.sh anywhere in ~/.bashrc, so I think we should add an adjustment to contrib/README.md.

akinomyoga commented 1 year ago

I added a sentence (d2c5eb3b7a6ff24498567d80ea8e0b7ee9f1a1c8) in README.md.


[[ ${BLE_VERSION-} ]] && ble-attach

## fzf 
## this works
source $XDG_CONFIG_HOME/bash/fzf.bash

I would expect that source fzf.bash would be placed before ble-attach (or doesn't it work?). When we use the source ble.sh --noattach & ble-attach pair, I expect that ble-attach is always at the bottom of ~/.bashrc.

Darukutsu commented 1 year ago

When I put it before ble-attach the following errors will appear (although it works):

ble.sh (bind): unsupported readline function 'emacs-editing-mode'.
ble.sh (bind): unsupported readline function 'emacs-editing-mode'.
ble.sh (bind): unsupported readline function 'vi-editing-mode'.

Putting it after doesn't show errors.

akinomyoga commented 1 year ago

Thanks for the information. I tried to reproduce it, but it doesn't seem to reproduce in my environment. Could you copy and paste the output of the following command in a ble.sh session?

$ ble/widget/display-shell-version
Darukutsu commented 1 year ago

GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) with ble.sh

akinomyoga commented 1 year ago

This means that you are using an old version of ble-0.4. I'm not sure which Linux distribution and package you are using, but could you update it to the latest version of ble-0.4?

Edit: Or another possibility would be that you are using ble-0.3, but ble-0.3 doesn't support contrib. In that case, it doesn't work anyway. You need to update it to ble-0.4.

Darukutsu commented 1 year ago

ah... I used AUR package v0.3.3 ... switching to blesh-git seems that it works as expected. Your config is correct.

akinomyoga commented 1 year ago

Ah, I now understand why the instructions were unclear to you. I guess you have cloned this repository separately. Just to make it clear, you don't need to clone the contrib repository (with ble-0.4) because the ble-0.4 package already includes the contents of contrib.

akinomyoga commented 1 year ago

I have updated the repository description to avoid confusion. Thanks!