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

Feature: preview window #46

Open
BartSte opened this issue Mar 22, 2024 · 2 comments
Open

Feature: preview window #46

BartSte opened this issue Mar 22, 2024 · 2 comments

Comments

@BartSte
Copy link
Contributor

BartSte commented Mar 22, 2024

Hey @wfxr,

Thanks for this repo. I use it everyday.

I created a fork where I added a preview window. Below I'll explain how it works. If you are interested, I can make a pull request such that it can be added to this repo. I tried to make it so that it is backwards compatible with the default configurations + it is turned off by default. In order to create the preview window (efficiently) I needed to extract the line numbers of the matches, using grep -n. This explains the changes that were made in the regexes. I created a separate script called preview.sh that handles the preview window.

Below you'll find a piece of documentation that I added to the README of my fork:

demo

This is a fork of wfxr/tmux-fzf-url with
a set of features added to it as is explained below. The goal is to keep this
repo up-to-date with the original one, and extend it with new features were
possible.

The following features have been added to this fork:

  • preview window: a preview window can be enabled that shows the content of
    the tmux buffer. The selected fzf line will be highlighted in the preview
    window. The preview window is disabled by default, and can be enabled by
    setting:

    set -g @fzf-url-fzf-preview true

    Note that it may be desirable to set a custom sort command, as is explained
    below.

  • sort command: after searching the tmux buffer, the results are presented
    in the following format: line_number:match. Here line_number is the line
    number in the tmux buffer, and match is the match. Before passing them to
    fzf, any duplicates are removed by using the sort -u command. Next, they are
    fed to a command that can be specified by the user. By default, the command is

    set -g @fzf-url-sort-cmd "sort -u -t: -k2"

    which means that only the match part is used for sorting this time, instead
    of the entire line. It will remove any duplicates, even if the line_number
    part is different. This will limit the number of lines that are shown in the
    fzf window, and will make it easier to find the desired line. However, when
    using the preview window, it may be desirable to display all the lines, such
    that you can scroll through them. In this case, the following may be more
    suitable:

    set -g @fzf-url-sort-cmd "sort -n"

    This will only sort the line_number part, and will not remove any
    duplicates.

@sproclavism
Copy link

Awesome job Bart, this is exactly what I needed.

By the way, as the newest (most relevant) links in a terminal would be at the bottom, passing an extra sorting option -r to reverse results works nicely.

@BartSte
Copy link
Contributor Author

BartSte commented Aug 5, 2024

Thanks! Good to hear it is useful for you. I added some more changes to my fork and eventually moved it to a new repo called tmux-fzf-open, since it started to deviate too much from the original project. Maybe it will be of interest for you as wel.

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