Skip to content

Instantly share code, notes, and snippets.

@rkitover
Last active May 6, 2024 23:12
Show Gist options
  • Save rkitover/970543715c23976ca86a6c3390f2cbf2 to your computer and use it in GitHub Desktop.
Save rkitover/970543715c23976ca86a6c3390f2cbf2 to your computer and use it in GitHub Desktop.
Setup ble.sh for PowerShell-like history completion in bash

Setup ble.sh for PowerShell-like history completion in bash

These settings will give you PowerShell-like history completion in bash using ble.sh.

History completions will be displayed in grey, press UP-ARROW or F8 to accept the completion and ENTER.

To cancel a completion, press CTRL-K or DOWN-ARROW.

When a completion is not active, use UP-ARROW and DOWN-ARROW to search history with the current text as a prefix and press ENTER to accept a history match and execute it.

Clone the ble.sh repository and build it

mkdir -p ~/source/repos
cd ~/source/repos
git clone https://github.com/akinomyoga/ble.sh.git --recurse-submodules
cd ble.sh
make

Install in your .bashrc

source ~/source/repos/ble.sh/out/ble.sh

ble-face -s auto_complete bg=none,fg=grey

ble-bind -m auto_complete -f right   forward-char
ble-bind -m auto_complete -f left    backward-char
ble-bind -m auto_complete -f f8      auto_complete/insert
ble-bind -m auto_complete -f up      auto_complete/insert
ble-bind -m auto_complete -f down    auto_complete/cancel
ble-bind -m auto_complete -f M-right auto_complete/insert-fword
ble-bind -m auto_complete -f M-f     auto_complete/insert-fword

ble-bind -f up   history-search-backward
ble-bind -f down history-search-forward

ble-bind -m nsearch -f RET nsearch/accept-line
ble-bind -m nsearch -f C-m nsearch/accept-line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment