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

fish: In ^r, multiline commands become multiple separate commands #436

Closed
tomfitzhenry opened this issue Dec 8, 2015 · 11 comments · Fixed by #954
Closed

fish: In ^r, multiline commands become multiple separate commands #436

tomfitzhenry opened this issue Dec 8, 2015 · 11 comments · Fixed by #954

Comments

@tomfitzhenry
Copy link
Contributor

Steps to reproduce:

First execute a multiline command, e.g.

for i in *
    echo $i
end

Then try to retrieve that: ^r echo

Expected:

fzf to return...

for i in *
    echo $i
end

Actual:

fzf returns...
echo $i

@tomfitzhenry
Copy link
Contributor Author

This works fine in bash (related: #146 ) and zsh (related: #142 ).

@tomfitzhenry
Copy link
Contributor Author

The problem is that fzf's fish plugin uses history (see

history | eval (__fzfcmd) +s +m --tiebreak=index --toggle-sort=ctrl-r > $TMPDIR/fzf.result
) will print multiline commands as multiple separate commands, e.g.

$ for i in 1 2 3
    echo $i
end
1
2
3
$ history
for i in 1 2 3
echo $i
end

@junegunn
Copy link
Owner

junegunn commented Dec 8, 2015

Thanks for the report, but unfortunately I don't know how to fix this, I don't use fish, so.. Got any idea?

@tomfitzhenry
Copy link
Contributor Author

cat ~/.config/fish/fish_history | grep '^- cmd' | cut -d ' ' -f 3- could be used as an alternative to history, but it is hacky.

This returns a string with escaped newline characters in, e.g
for i in 1 2 3 \n echo $i \n end
I need to find a way to un-escape those escaped newline charcaters, so it appears as:

for i in 1 2 3
echo $i
end

@leiserfg
Copy link

leiserfg commented Dec 9, 2015

For un-escape just use printf.

@leiserfg
Copy link

leiserfg commented Dec 9, 2015

In fish the $history var holds all the the commands as an array. It could be used to solve it without hack the history file.

@hauleth
Copy link

hauleth commented Feb 10, 2016

The best way to deal with that would be adding -0 flag to Fish history that would split history entries using \0 instead of newline.

@amosbird
Copy link
Contributor

hmm, does fzf support multiline items now? since fish history -z will produce NUL separated strings.

@tomfitzhenry
Copy link
Contributor Author

@tomfitzhenry
Copy link
Contributor Author

Better link: fish-shell/fish-shell@a26f68d

@amosbird
Copy link
Contributor

well, please notice there is one issue #953

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

Successfully merging a pull request may close this issue.

5 participants