Giter Site home page Giter Site logo

tmux-fzf-open's Introduction

tmux-fzf-open

Contents

Introduction

tmux-fzf-open is a tmux plugin for opening files/links from a tmux pane. It started as a fork of wfxr/tmux-fzf-url with a preview window added to it. Later, breaking changes were made to make it make configuration more flexible.

tmux-fzf-open has the following features:

  • open files/links in a tmux pane with fzf.
  • choose any program to open the item.
  • add your own regexes to capture more items.
  • set a custom sort command.
  • enable a preview window that shows the content of the tmux buffer.

demo

Installation

Dependencies:

Install using TPM

Add this line to your tmux config file:

set -g @plugin 'BartSte/tmux-fzf-open'

Install manually

Clone this repo and source the setup.tmux script in your tmux config file:

run "source /path/to/tmux-fzf-open/setup.tmux"

Usage

As can be seen in the demo, tmux-fzf-open is activated by pressing the prefix key (usually Ctrl+b), followed by u. This will open a fzf window with the items that are found in the tmux pane. The items are found by using a regex that is defined in the @fzf-url-regex option. By default, this regex is set to only match URLs and IP addresses. After you selected one or more items, they will be opened in the program that is defined in the @fzf-url-open-cmd option. By default, this is set to $BROWSER, but you should set it to another program if you also want to items that are not URLs or IP addresses.

Configuration

The following configuration is the default configuration:

# set -g @fzf-open-regex "<some long regex that matches URLs and IP addresses>"
set -g @fzf-open-extra-regexes "" # empty by default
set -g @fzf-open-open-limit "screen" # only the visible part of the screen is searched
set -g @fzf-open-open-cmd "$BROWSER" # the program that is used to open the items
set -g @fzf-open-sort-cmd "sort -u -t: -k2" # sort the items before passing them to fzf
set -g @fzf-open-fzf-opts "-w 100% -h 50% --multi -0" # fzf options
set -g @fzf-open-fzf-preview true # enable the preview window

Below, the options are explained in more detail:

  • regex: the regex that is used to find items in the tmux pane. By default, it is set to only match URLs and IP addresses. The default regex can be found in the fzf-open script.

  • extra regexes: if you want to extend the default regex, you can add your own regexes to the @fzf-open-extra-regexes option.

  • open limit: by default, only the visible part of the screen is searched for items. This can be changed by setting the @fzf-open-open-limit option to a number. This number is the number of lines that are searched. For example, if you set it to 5000, the first 5000 lines of the tmux buffer are searched for items.

  • open cmd: the program that is used to open the items. By default, it is set to $BROWSER, but you should set it to another program if you also want to items that are not URLs or IP addresses. For example, you can set it to xdg-open or open (if they are available on your system), which will open the items in the default program that is associated with the item.

  • 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.

    When the default command is used, only the match part is used for sorting. This 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 duplicated matches on different lines.

  • fzf options: the options that are passed to fzf. It is also possible to set the $FZF_OPEN_OPTS environment variable instead, as this conforms to the fzf way of configuring options. The tmux settings will take precedence over the environment variable.

  • 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.

Troubleshooting

If you encounter any issues, please report them on the issue tracker at: tmux-fzf-open issues

Contributing

Contributions are welcome! Please see CONTRIBUTING for more information.

License

Distributed under the MIT License.

tmux-fzf-open's People

Stargazers

Bart avatar

Watchers

Bart avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.