Giter VIP home page Giter VIP logo

tmux-fuzzback's Introduction

tmux-fuzzback

Build Status GitHub

tmux-fuzzback uses a fuzzy finder to search terminal scrollback buffer, and jump to selected position.

preview

Attribution

This plugin would not be possible without the work done in copycat. Go download it, use it, and give it some love. I also drew more than a little inspiration from tmux-fzf-url. Huge thanks to both.

Requirements

Installation

Using Tmux Plugin Manager (recommended)

set -g @plugin 'roosta/tmux-fuzzback'

Manually

git clone https://github.com/roosta/tmux-fuzzback.git

Add this to the bottom of .tmux.conf

run-shell ~/path/to/repo/fuzzback.tmux

Reload TMUX env

tmux source-file ~/.tmux.conf

Usage

To use tmux-fuzzback, start it in a tmux session by typing prefix + ?. Now you can start fuzzy searching in your scrollback buffer using fzf.

Options

Fuzzy finder

Fuzzback uses fzf as default, but you can set it to sk if you'd rather use skim

set -g @fuzzback-finder 'sk'

Fuzzback was built using fzf, and only later did I add support for skim. These two finders seem mostly comparable, although I might have missed something. Please open an issue if you find any problems with this or other.

Additionally the popup window doesn't seem to work in sk-tmux, I'm unable to open it on tmux next-3.4 and sk 0.10.2, so it isn't currently configured to work.

Key binding

The default key-binding is ? preceded by a prefix, it can be modified by setting value to @fuzzback-bind in the tmux config like this:

set -g @fuzzback-bind s

Make sure this setting is set before loading the plugin.

Enable popup

You can enable tmux popup by setting this variable in your tmux conf. Keep in mind that only recent versions 3.2 and above of tmux support this.

set -g @fuzzback-popup 1

Only works with fzf for the time being

Hide preview

Preview is shown by default, but you can hide it initially by setting fuzzback-hide-preview to 1.

set -g @fuzzback-hide-preview 1

You can still toggle it back with your preferred keybinding (fzf default ctrl+p)

Popup size

You can set the popup size with this option.

set -g @fuzzback-popup-size '90%'

Finder layout

You can reverse the direction of selected finder by setting this variable. The default is default

set -g @fuzzback-finder-layout 'reverse'

Finder bind

If you want to bind some keybinding using sk/fzf --bind that's only used in fuzzback set this variable.

set -g @fuzzback-finder-bind 'ctrl-y:execute-silent(echo -n {3..} | xsel -ib)+abort'

This will copy the line matches in selected finder to the clipboard if xsel is available.

Refer documentation for more:

Toggling sort

If you need to toggle sort on and off you could add this to your fuzzback config

set -g @fuzzback-finder-bind 'ctrl-s:toggle-sort'

FZF colors

You can add colors to fuzzback as you do with fzf.

set -g @fuzzback-fzf-colors 'bg+:#100E23,gutter:#323F4E,pointer:#F48FB1,info:#ffe6b3,hl:#F48FB1,hl+:#63f2f1'

All highlight options can be found in fzf's man page.

Keybind table

Normally the fuzzback keybind will go into the prefix table, but if you want to activate fuzzback without typing the prefix, you can change the table here. Say you wanted to activate fuzzback without prefix:

# this is the same as bind-key -n
set -g @fuzzback-table 'root'

Make sure this option, same as keybind, is set before loading the plugin.

Limitations

Column movement

Depending on the complexity of the search query, fuzzback might not know what column to move to, and will place you at the start of the line unless a literal match can be found.

Developing

You can run tests locally using Vagrant by calling:

# cd project root
./run_tests

License

MIT

tmux-fuzzback's People

Contributors

eggbean avatar hqkhan avatar jakubgros avatar kevintraver avatar mohamedosman1998 avatar roosta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tmux-fuzzback's Issues

Copy command is also copying the line number

When I hit my copy command, ctrl-y using my normal shell interface, I get the line, as is:

Screen Shot 2021-07-22 at 9 57 44 AM

Copied to clipboard: npm run test:cypress:open

Using this plugin, it is copying some "invisible" line number with it. I would blame my config but it works fine except with this plugin.

Screen Shot 2021-07-22 at 10 15 25 AM

Copied to clipboard: 5:❯ fzf-tmux -p

Maybe this should be overrideable?
https://github.com/roosta/tmux-fuzzback/blob/main/scripts/fuzzback.sh#L17-L25

I notice my copy command is this --bind 'ctrl-y:execute-silent(echo -n {2..} | pbcopy)+abort' which maybe doesn't match what the FZF_DEFAULT_OPTS this plugin outputs 🤔

Split arg is not percent

I think this is a bug in fzf-tmux, it wont take percentages anymore, only line numbers, so what I thought was 50% was actually 50 line numbers, which cause issues on smaller splits.

Strange sorting behaviour

Sorting seem to be broken for me. In this example I use asdf to list all plugins asdf plugin-list-all and trying to look for nodejs plugin in the list.
image

Here I piped the output of the command directly into fzf and it works as expected, finding the longest matching substring:

image

❯ zsh --version
zsh 5.9 (x86_64-ubuntu-linux-gnu)

❯ tmux -V
tmux 3.3a

❯ fzf --version
0.42.0 (d471067)

Fuzzy finding only between output from last command

Hello! I wanted to ask if there's a way to only fuzzy find within stdout from last executed command. I run a lot of tests and sometimes I'm looking for specific string inside output that gets matched from one of my old runs.

I realize that I could output everything into a file and find in there but I was wondering if I can do that strictly from stdout.

"returned 1" and doesn't copy

Great looking plugin! I gave it a spin and FZF pulls up fine but when I hit "enter" on a line I get the below message and it doesn't seem to copy. Can I provide any more info?

[my machine]/.tmux/plugins/tmux-fuzzback/scripts/fuzzback.sh' returned 1

[request] option to disable the fzf preview window

TLDR:

Disable the fzf preview window by default and add an option like for ex:

set -g @fuzzback-fzf-previews-enabled 1

Hi,

long time user and fan of this extremely usefull and clever plugin. By the way, I also use Arch ...

I dont like that fzf preview window being forced by default. Too much clutter for my taste.
I also tend to use tmux-fuzzback to "bulk collect" items.
Could be urls, or "ids" or whatever that was displayed in my long tmux scroll back buffer.
I dont use it in "popup" mode, I use it in "split" mode in this case.
Here is a silly example, where I'm collection youtube "ChannelID"s, https://asciinema.org/a/4eeL2XwAvuf2IGi37xKu5H5TU

This allows me to filter and "shrink" my tmux scrollback buffer to only a list of items I'm interested in. I then use tmux copy-mode to copy those items, all at once to a tmux-buffer. Very nice

The thing is that by default, tmux-fuzzback, has the preview option for fzf enabled.
So that on the right side there is a big block of text I dont need.

And I dont want this, as I dont need any context and dont want to preview those lines.
I just want the items in a nice list.

So I went ahead and edited "fuzzback.sh", to comment out that part

finder_split_cmd() {
  local fuzzback_finder="$3"
...
...
    --no-sort \
    # 2023-03-28 commented out to disable the fzf preview
    # --preview-window=nowrap \
    # --preview="$CURRENT_DIR/preview.sh $CAPTURE_FILENAME {}" \
    --print-query \
....
....
}

It seems to work without problems. But now I have changed and customized your script.

I would rather prefer if this was offered as an option, so that I can just install fuzzback without having to hack it.

Something like a boolean option, to enable/disable fzf previews, for example

set -g @fuzzback-fzf-previews-enable 1

And by default they are disabled, as I find it distracting.

Thanks in advance

Add a new option or parameter to enable "--no-sort"

Hi,

I've used this plugin for a period of time and I met a problem on the history search. In my case, I'd like to jump to the earliest keyword appeared. For example, when there are some compilation errors appeared, I'd like to jump to the earliest one. However, without --no-sort, fzf would mess up the result.

I've tried to modify $FZF_DEFAULT_OPT that does not work as there is no preserved position for appending --no-sort in the fuzzback.sh. I think this feature would be helpful if it could be added. Thanks.

Selection_010

FZF preview scrollback

Thanks @roosta for this wonderful plugin.

Feature Request
Just wanted to check if it is possible to add a preview(with context) of the focussed line in the fzf matches. This will help to read the neighbouring lines as well.

Having trouble installing

Is this still maintained? I couldn't get the prefix+ ? to do anything when I installed it. I installed via tpm and couldn't get anything. I changed keybind from README but it still didn't do anything.

I tried using feat/preview branch but still couldn't get any response. Any idea as to what I'm missing?

[Not an Issue] Added colors as an option

This isn't an issue but something I wanted to share. I added fuzzback-fzf-color option to the config to have different colors instead. I was originally thinking of adding an env variable but that would require users to set it only for fuzzback and the code wouldn't be contained. Although I do have colors for normal bash, this option was kinda neat and simple to add. Basically the same way bind is added.

I'd be happy to make a PR if interested or I'm good just keeping it to myself as well but thought I'd share!

(The default colors make it quite hard to see anything for me)

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.