Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Fzf is great, but unfortunately it doesn't have line wrap (there's an open bug basically marked as WONTFIX). So if you frequently work with long commands and want to use fzf to search for older commands with Ctrl-R, things will be quite complicated :-(


There's an easy workaround. I use a keybinding such that when searching through commands with Ctrl-R I can press ? to display the the full wrapped command in a preview window at the bottom of the screen.

My Ctrl-R config is at https://gist.github.com/brbsix/5e4f18833133b3accac78e3331292... but the line below is the relevant bit:

    # View full command in preview window (?)
    export FZF_CTRL_R_OPTS="${FZF_CTRL_R_OPTS:+$FZF_CTRL_R_OPTS }--preview 'echo {}' --preview-window down:5:hidden:wrap --bind '?:toggle-preview'"


Couldn't you "one time" process your history file to remove the line wraps (and make it appear that you ran a bunch of very long commands)?


You're misreading what I'm saying, it's the other way around. fzf doesn't support line wrapping very long lines.

I have really long commands in my shell history and fzf just truncates them, which makes it pretty useless in many cases, since those commands are similar or identical up to 80-100-120 characters.

So in many situations I kind of have to guess which command has the parameter that I want at the end.

It's not that my shell history has lines with line wrap in them, it's that fzf can't show long commands on multiple lines so that I can see the entire command...


As a hack, you could do pre process to hide some of the common prefix, pass it into FZF, and then post process to add back the prefix, before finally running it.

Basically, something like:

    history | strip-prefix | fzf | add-prefix | bash
I'm not sure if it would be useful, but I think it's worth a try (and would be a fun project).


Ah that makes more sense and seems like a serious limitation




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: