mirror of
https://github.com/atuinsh/atuin.git
synced 2025-02-03 20:19:55 +01:00
feat(bash): provide auto-complete source for ble.sh (#1487)
* feat(bash): provide auto-complete source for ble.sh * docs(integration): mention the auto-complete source for ble.sh
This commit is contained in:
parent
16309ca198
commit
434e8238d8
@ -133,6 +133,24 @@ __atuin_history() {
|
||||
# shellcheck disable=SC2154
|
||||
if [[ -n "${BLE_VERSION-}" ]] && ((_ble_version >= 400)); then
|
||||
ble-import contrib/integration/bash-preexec
|
||||
|
||||
# Define and register an autosuggestion source for ble.sh's auto-complete.
|
||||
# If you'd like to overwrite this, define the same name of shell function
|
||||
# after the $(atuin init bash) line in your .bashrc. If you do not need
|
||||
# the auto-complete source by atuin, please add the following code to
|
||||
# remove the entry after the $(atuin init bash) line in your .bashrc:
|
||||
#
|
||||
# ble/util/import/eval-after-load core-complete '
|
||||
# ble/array#remove _ble_complete_auto_source atuin-history'
|
||||
#
|
||||
function ble/complete/auto-complete/source:atuin-history {
|
||||
local suggestion
|
||||
suggestion=$(atuin search --cmd-only --limit 1 --search-mode prefix "$_ble_edit_str")
|
||||
[[ $suggestion == "$_ble_edit_str"?* ]] || return 1
|
||||
ble/complete/auto-complete/enter h 0 "${suggestion:${#_ble_edit_str}}" '' "$suggestion"
|
||||
}
|
||||
ble/util/import/eval-after-load core-complete '
|
||||
ble/array#unshift _ble_complete_auto_source atuin-history'
|
||||
fi
|
||||
precmd_functions+=(__atuin_precmd)
|
||||
preexec_functions+=(__atuin_preexec)
|
||||
|
@ -5,3 +5,18 @@
|
||||
Atuin automatically adds itself as an [autosuggest strategy](https://github.com/zsh-users/zsh-autosuggestions#suggestion-strategy).
|
||||
|
||||
If you'd like to override this, add your own config after "$(atuin init zsh)" in your zshrc.
|
||||
|
||||
## ble.sh auto-complete (Bash)
|
||||
|
||||
If ble.sh is available when Atuin's integration is loaded in Bash, Atuin automatically defines and registers an auto-complete source for the autosuggestion feature of ble.sh.
|
||||
|
||||
If you'd like to change the behavior, please overwrite the shell function `ble/complete/auto-complete/source:atuin-history` after `eval "$(atuin init bash)"` in your `.bashrc`.
|
||||
|
||||
If you would not like Atuin's auto-complete source, please add the following setting after `eval "$(atuin init bash)"` in your `.bashrc`:
|
||||
|
||||
```shell
|
||||
# bashrc (after eval "$(atuin init bash)")
|
||||
|
||||
ble/util/import/eval-after-load core-complete '
|
||||
ble/array#remove _ble_complete_auto_source atuin-history'
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user