The zsh version of the cd widget sets the variable `dir` to the path of
the target directory before invoking `cd`. This causes zsh to treat the
target directory as a named directory, which has the effect of zsh
substituting '%~' with '~dir' instead of the proper path when it
performs prompt expansion.
This commit will cause the widget to unset `dir` before redrawing the
prompt to fix this issue.
Details of zsh prompt expansion can be found in:
http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html
* Don't do shell quoting for weird chars
This would prevent tabs from being escaped as `$'\t'` (definitely not what I would want to see as initial value in the search).
* Do different escape.
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