A shell script that replaces the default CTRL+r
behavior in bash
. It uses fzf
to select a command from ~/.bash_history
and insert the selected command into the prompt. It also copy the selected command to the clipboard, so you can paste it somewhere else.
- Install
fzf
(your distro's packages repository probably has it available to install) - (optional) Install
xclip
orxsel
(your distro probably has one of them already installed). - Copy the
ctrlr.sh
file to/usr/local/bin/
(you can copy it to another directory if you wish) - Make it executable:
chmod +x /usr/local/bin/ctrlr.sh
- Override the vanilla
CTRL+r
adding the following line to the end of your~/.bashrc
:
bind -x '"\C-r": "source /usr/local/bin/ctrlr.sh"'
- Restart the terminal
- Be happy
ctrlr.sh
is released under the MIT License.