Fzf: Make it possible to specify history options in CTRL-R?

Created on 4 Jun 2018  路  4Comments  路  Source: junegunn/fzf

  • Category

    • [x] Key bindings

  • Shell

    • [x] zsh

I was hoping FZF_CTRL_R_OPTS would allow me to specify options to send to history but after reading fzf_history_widget in key-bindings.zsh it looks like that's not possible. I'd like to be able to configure history output to show timestamps, like history -i.

question

Most helpful comment

I suggest that you just override the implementation in your shell configuration file. It's just a few lines of code.

In case anyone else finds this issue and is interested, here's what I wound up doing. In my script that installs all my stuff, I patch key-bindings.zsh like so:

perl -pi -e 's/fc -rl 1/fc -rli 1/' "$(brew --prefix fzf)/shell/key-bindings.zsh"

All 4 comments

The problem is that if we change the format of the input, the subsequent processing of the selected line should be changed accordingly, so we can't just allow users to use any command via FZF_CTRL_R_COMMAND, because it may not work. For example, CTRL-R implementation for zsh expects the selected line to start with a number so it can restore the old command with zle vi-fetch-history, but if the line starts with a timestamp, for example, vi-fetch-history will fail. So it's tricky to make the command configurable while not breaking the feature.

I suggest that you just override the implementation in your shell configuration file. It's just a few lines of code.

For example, CTRL-R implementation for zsh expects the selected line to start with a number...

If you do history -i the format is "[number] [timestamp] [historyline]", so it'll still start with a number.

I figured you could do something like:

selected=( $(fc -rl $FZF_HISTORY_OPTS 1 |

Thanks anyway for considering! And thanks for fzf!

I suggest that you just override the implementation in your shell configuration file. It's just a few lines of code.

In case anyone else finds this issue and is interested, here's what I wound up doing. In my script that installs all my stuff, I patch key-bindings.zsh like so:

perl -pi -e 's/fc -rl 1/fc -rli 1/' "$(brew --prefix fzf)/shell/key-bindings.zsh"

@kbd thanks your tips and thanks for fzf again.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

olethanh picture olethanh  路  3Comments

firedev picture firedev  路  3Comments

jan-warchol picture jan-warchol  路  3Comments

aleclarson picture aleclarson  路  3Comments