Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline item's separator doesn't use '\n' #953

Closed
3 of 15 tasks
amosbird opened this issue Jun 22, 2017 · 2 comments
Closed
3 of 15 tasks

Multiline item's separator doesn't use '\n' #953

amosbird opened this issue Jun 22, 2017 · 2 comments

Comments

@amosbird
Copy link
Contributor

  • Category
    • fzf binary
    • fzf-tmux script
    • Key bindings
    • Completion
    • Vim
    • Neovim
    • Etc.
  • OS
    • Linux
    • Mac OS X
    • Windows
    • Windows Subsystem for Linux
    • Etc.
  • Shell
    • bash
    • zsh
    • 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.

@junegunn
Copy link
Owner

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?

@amosbird
Copy link
Contributor Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants