Skip to content

Peter-McKinney/tmux-fzf-open-files-nvim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TMUX fzf Open Files nvim

A tmux plugin to parse terminal output for filenames and open them in neovim. It works by creating a tmux binding to copy the currently selected panes content, match output that is a file path ending in an extension or with location information 83:57, pass the file paths to fzf, and open the fzf selected files in your default $EDITOR (only tested with neovim currently). The plugin will search for panes in the current window running neovim and open the selected files as new tabs. If a current neovim instances does not exist, a new horizontal pane will be created to host neovim and the files will be opened there.

current-pane-visible.mp4

tmux-fzf-open-files-nvim works on large histories as well:

large-history.mp4

Tests Run shellcheck

Installation

TPM

Using TPM, add the following lines to your ~/.tmux.conf:

set -g @plugin 'Peter-McKinney/tmux-open-file-nvim'

Use prefix + I to install the plugin which should also source your ~/.tmux.conf but just in case: prefix + :source ~/.tmux.conf

Make sure to have your editor environment variable set to neovim:

export EDITOR='nvim'

Please make sure that fzf is installed by following the directions over at: https://github.com/junegunn/fzf

Usage

Keybindings:

Variable Name Description Default Binding
@open-file-nvim-key Parses the current visible pane output for filenames prefix + o
@open-file-nvim-all-key Parses the entire available history in the current pane for filenames prefix + O
@open-file-nvim-all-history-key Parses the entire history from all panes in a window prefix + A

Capture the output visible in the current pane:

The default binding uses o so prefix + o will run the process to find files in the current pane output. A new horizontal pane will be opened to the right of the current pane. The pane visible text will be sent to fzf -m multi select mode so that multiple files may be selected and sent to the $EDITOR.

current-pane-visible.mp4

Capture the entire history of the current pane:

The default binding uses O so prefix + O will run the above process for the entire history of the current pane.

current-pane-history.mp4

Capture the entire history of all panes in a window:

The default binding uses A so prefix + A will run the above process for the entire history of all panes in a tmux window. This operation can be expensive.

all-pane-history.mp4

Change the default bindings

set -g @open-file-nvim-key {newbinding}
set -g @open-file-nvim-all-key {newbinding}
set -g @open-file-nvim-all-history-key {newbinding}

Development

Link plugin source locally for testing

In the dev folder, there are scripts to automate linking the plugin locally for development / testing and for resetting the local link to the github link. The scripts edit the ~/.tmux.conf and use the tpm clean and install scripts found in ~/.tmux/plugins/tpm/bin to remove and install plugins. dev/link-plugin-locally.sh creates a symbolic link to ~/github/tmux-fzf-open-files-nvim. Change this to where your cloned repository resides. You can then run dev/link-plugin-locally.sh to restore the github plugin source.

Setting up unit tests and running using bats

We use the bats unit test framework to write and execute bash unit tests https://github.com/bats-core/bats-core. Refer to https://bats-core.readthedocs.io/en/stable/installation.html for the full installation instructions. Here are common ones:

MacOS using homebrew:

brew install bats-core

Ubuntu:

sudo apt install bats

To run the unit tests:

bats tests

Github Actions

Shellcheck

We use shellcheck to perform static analysis as a PR check. To install shellcheck locally refer to the installation guide in the shellcheck github. You can also use https://www.shellcheck.net/

To run shellcheck on all files in the project locally run dev/run-shellcheck.sh.

Warnings will not cause the github action check to fail, only errors.

Shfmt

We use shfmt to ensure consistent formatting. You can run formatting on the project by running dev/run-format.sh

We also run the bats tests as a part of the PR check workflow, which is covered under the unit testing section. But since you're here: bats tests will execute the unit tests for the project.

About

Open files in neovim from panes in the current tmux window!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages