akinomyoga / ble.sh

Bash Line Editor―a line editor written in pure Bash with syntax highlighting, auto suggestions, vim modes, etc. for Bash interactive sessions.
BSD 3-Clause "New" or "Revised" License
2.32k stars 77 forks source link

[starship] eval after bleopt necessary? #333

Open teutat3s opened 1 year ago

teutat3s commented 1 year ago

ble version: 0.4.0-devel4+f16c0d8 Bash version: 5.2.15(1)-release (x86_64-pc-linux-gnu)

In /etc/bashrc I have:

if [[ $TERM != "dumb" && (-z $INSIDE_EMACS || $INSIDE_EMACS == "vterm") ]]; then
  export STARSHIP_CONFIG=/nix/store/h9cak4nnnlsb52hvm79pggz9abb848gl-starship.toml
  eval "$(/nix/store/phcx9a2plh8gs0a5xz18chg1bywfymr1-starship-1.15.0/bin/starship init bash)"
fi

When using the newest version of ble.sh (latest commit from master branch), I need to run the eval command a second time in ~/.bashrc after the section with all bleopt and ble-bind statements, just before [[ ${BLE_VERSION-} ]] && ble-attach

~/.bashrc

...
bleopt complete_menu_style=desc

# Bash vim mode keybindings
if [[ $- == *i* ]]; then # in interactive session
  set -o vi

  ble-bind -m vi_imap -f 'ENTER' 'vi_imap/complete'
  ble-bind -m vi_imap -f 'TAB' 'vi_imap/complete'

  ble-bind -m vi_imap -f 'j j' 'vi_imap/normal-mode'
  ble-bind -m vi_imap -f 'ESC' 'vi_imap/normal-mode'

  ble-bind -m vi_nmap -f 'h' 'vi_nmap/insert-mode'
  ble-bind -m vi_nmap -f 'i' 'vi-command/backward-line'
  ble-bind -m vi_nmap -f 'j' 'vi-command/backward-char'
  ble-bind -m vi_nmap -f 'k' 'vi-command/forward-line'
  ble-bind -m vi_nmap -f 'l' 'vi-command/forward-char'

  ble-bind -m vi_imap -f 'C-c' discard-line
fi

# end of .bashrc

# Somehow we need to ensure starship starts later than ble.sh
eval "$(/nix/store/phcx9a2plh8gs0a5xz18chg1bywfymr1-starship-1.15.0/bin/starship init bash)"

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

...

I am unsure if this is a packaging issue, as this happens on NixOS 23.05, with a custom packaged version of ble.sh. When using the provided 0.4.0-devel3 release archive from GitHub, the change is not required for starship to start with a single eval in /etc/bashrc.

Without the second eval, ble.sh 0.4.0-devel4+f16c0d8 starts fine, but I only see the bash:$ prompt instead of the starship prompt.

akinomyoga commented 10 months ago

Sorry for the long blank, but the provided context is unclear. At least, I cannot reproduce the problem with the settings you provided.

The general answer to a question on the ordering of the configuration is mentioned in README §1.3. Whether eval after sourcing ble.sh is really necessary or not depends on the situation, (which is not clear for the present case by the provided information), but you should also look at https://github.com/akinomyoga/ble.sh/discussions/254#discussioncomment-4284757 which is linked from README §1.3.

To answer the question for your specific case, I need clarifications and context from you. I'm sorry, but I need to ask many quetions.

In /etc/bashrc I have:

I need to run the eval command a second time in ~/.bashrc after the section with all bleopt and ble-bind statements, just before [[ ${BLE_VERSION-} ]] && ble-attach

I am unsure if this is a packaging issue, as this happens on NixOS 23.05, with a custom packaged version of ble.sh. When using the provided 0.4.0-devel3 release archive from GitHub, the change is not required for starship to start with a single eval in /etc/bashrc.