CTRL-R binding used to start with --no-sort to list the matched commands
in chronological order. However, it has been a constant source of
confusion. Let's enable it by default from now on. The sorted result
shouldn't be too confusing as we use --tiebreak=index.
zle automatically calls zle-line-init when it starts to read a new line. Many
Zsh setups use this hook to set the terminal into application mode, since this
will then allow defining keybinds based on the $terminfo variable (the escape
codes in said variable are only valid in application mode).
However, fzf resets the terminal into raw mode, rendering $terminfo values
invalid once the widget has finished. Accordingly, keyboard bindings defined
via $terminfo won’t work anymore.
This fixes the issue by calling zle-line-init when widgets finish. Care is taken
to not call this widget when it is undefined.
Fixes#279
This allows to have a custom widget like the following, which would
additionally accept the line, but only in case of entries being
selected:
fzf-file-widget-with-accept() {
zle fzf-file-widget
if [[ "$?" == 0 ]] && (( $#BUFFER )); then
zle accept-line
fi
}
zle -N fzf-file-widget-with-accept
bindkey '\e^T' fzf-file-widget-with-accept
With this `<C-a>t` will launch fzf, and simulate the pressing of "Enter"
afterwards.
In the case that fzf-tmux returns a user-selected result but with a
non-zero exit status (which can happen if a function inside $PS1 returns
non-zero) this allows CTRL-R to continue working as expected.
Addresses #203 (Tranquility's comment)
In addition to being simpler, it allows subsequent up/down history
or accept-line-and-down-history widgets to work.
Also allow for find being and alias if alias expansion
after command is enabled.
- Use symlinks instead of generating the full content
- Update fish_user_paths and remove ~/.config/fish/functions/fzf.fish
- Create wrapper script for fzf when Ruby version and use it instead of
exported function not to break fzf-tmux