mirror of
https://github.com/junegunn/fzf.git
synced 2025-11-18 08:13:40 -05:00
add section readline; add ctrl-r script
59
Examples.md
59
Examples.md
@@ -86,6 +86,8 @@ Replacing `eval` with `print -z` will push the arguments onto the editing buffer
|
||||
|
||||
#### With write to terminal capabilities
|
||||
|
||||
This have been tested in bash.
|
||||
|
||||
```sh
|
||||
# utility function used to write the command in the shell
|
||||
writecmd() {
|
||||
@@ -103,7 +105,39 @@ fhe() {
|
||||
}
|
||||
```
|
||||
|
||||
This have been tested in bash.
|
||||
```sh
|
||||
# Another CTRL-R script to insert the selected command from history into the command line/region
|
||||
__fzf_history ()
|
||||
{
|
||||
builtin history -a;
|
||||
builtin history -c;
|
||||
builtin history -r;
|
||||
builtin typeset \
|
||||
READLINE_LINE_OLD="$READLINE_LINE" \
|
||||
READLINE_POINT_OLD="$READLINE_POINT"\
|
||||
READLINE_LINE_NEW="$(
|
||||
HISTTIMEFORMAT= builtin history |
|
||||
command fzf +s --tac +m -n2..,.. --tiebreak=index --toggle-sort=ctrl-r |
|
||||
command sed '
|
||||
/^ *[0-9]/ {
|
||||
s/ *\([0-9]*\) .*/!\1/;
|
||||
b end;
|
||||
};
|
||||
d;
|
||||
: end
|
||||
'
|
||||
)";
|
||||
|
||||
READLINE_LINE="${READLINE_LINE_OLD:+${READLINE_LINE_OLD:0:READLINE_POINT_OLD}}${READLINE_LINE_NEW}${READLINE_LINE_OLD:+${READLINE_LINE_OLD:READLINE_POINT_OLD}}";
|
||||
READLINE_POINT="$((READLINE_POINT_OLD + ${#READLINE_LINE_NEW}))"
|
||||
}
|
||||
|
||||
builtin set -o histexpand;
|
||||
builtin bind '"\er": redraw-current-line';
|
||||
builtin bind '"\e^": magic-space';
|
||||
builtin bind -x '"\C-x1": __fzf_history';
|
||||
builtin bind '"\C-r": "\C-x1\e^\er"'
|
||||
```
|
||||
|
||||
### Processes
|
||||
|
||||
@@ -349,6 +383,25 @@ zle -N fzf-locate-widget
|
||||
bindkey '\ei' fzf-locate-widget
|
||||
```
|
||||
|
||||
### Readline
|
||||
|
||||
```sh
|
||||
# CTRL-X-1 - Invoke Readline functions by name
|
||||
__fzf_readline ()
|
||||
{
|
||||
builtin eval "
|
||||
builtin bind ' \
|
||||
\"\C-x3\": $(
|
||||
builtin bind -l | command fzf +s +m --toggle-sort=ctrl-r
|
||||
) \
|
||||
'
|
||||
"
|
||||
}
|
||||
|
||||
builtin bind -x '"\C-x2": __fzf_readline';
|
||||
builtin bind '"\C-x1": "\C-x2\C-x3"'
|
||||
```
|
||||
|
||||
### RVM
|
||||
|
||||
```sh
|
||||
@@ -367,10 +420,10 @@ frb() {
|
||||
# fzf-wrapper
|
||||
# https://github.com/D630/fzf-wrapper
|
||||
% . fzf-wrapper
|
||||
% [<ENV>] __fzf_wrapper [<ARGS>]
|
||||
% [<ENV>...] __fzf_wrapper [<ARG>...]
|
||||
```
|
||||
|
||||
###Vagrant
|
||||
### Vagrant
|
||||
|
||||
You must have [`jq`](https://github.com/stedolan/jq) installed on your computer in order to use this function.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user