Fzf: Multiline item's separator doesn't use '\n'

Created on 22 Jun 2017  路  2Comments  路  Source: junegunn/fzf

  • Category

    • [ ] fzf binary

    • [ ] fzf-tmux script

    • [ ] Key bindings

    • [x] Completion

    • [ ] Vim

    • [ ] Neovim

    • [ ] Etc.

  • OS

    • [x] Linux

    • [ ] Mac OS X

    • [ ] Windows

    • [ ] Windows Subsystem for Linux

    • [ ] Etc.

  • Shell

    • [ ] bash

    • [ ] zsh

    • [x] fish

I'm trying to get multiline history completion work by history -z | fzf --read0. However it generates items that are not separated by \n but \? which breaks command line substitution.

Most helpful comment

fzf does not officially support multi-line entries, and with the premise, a new line character is not a valid character fzf can properly display on screen, and fzf prints it as ? character instead. I know it is not ideal, but it's how it works right now.

fzf displays those characters as ?, but that does not affect the final output of fzf, so you can still depend on it.

> echo -en "foo\nbar" | fzf --read0 --select-1 | wc -l
       2

Notice that we have no issues with multi-line commands in bash and zsh, as history and fc -l 1 commands of them are smart enough to transform a multi-line command into a single-line entry.

$ a() {
> 1
> 2
> }
$ HISTTIMEFORMAT= history | tail -2
94918  a() { 1; 2; }
94919  HISTTIMEFORMAT= history | tail -2
$

Maybe fish can do something similar?

All 2 comments

fzf does not officially support multi-line entries, and with the premise, a new line character is not a valid character fzf can properly display on screen, and fzf prints it as ? character instead. I know it is not ideal, but it's how it works right now.

fzf displays those characters as ?, but that does not affect the final output of fzf, so you can still depend on it.

> echo -en "foo\nbar" | fzf --read0 --select-1 | wc -l
       2

Notice that we have no issues with multi-line commands in bash and zsh, as history and fc -l 1 commands of them are smart enough to transform a multi-line command into a single-line entry.

$ a() {
> 1
> 2
> }
$ HISTTIMEFORMAT= history | tail -2
94918  a() { 1; 2; }
94919  HISTTIMEFORMAT= history | tail -2
$

Maybe fish can do something similar?

ah, fish's read command also needs a -z flag. This works history -z | eval (__fzfcmd) --read0 -q '$str' | read -lz result

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alistaircolling picture alistaircolling  路  3Comments

leonklingele picture leonklingele  路  3Comments

nordlow picture nordlow  路  3Comments

jberglinds picture jberglinds  路  3Comments

olethanh picture olethanh  路  3Comments