A lightning fast version of tmux-fingers written in Rust, copy/pasting tmux like vimium/vimperator

Overview

tmux-thumbs

A lightning fast version of tmux-fingers written in Rust for copy pasting with vimium/vimperator like hints.

Usage

Press ( prefix + Space ) to highlist in you current tmux visible pane all text that match specific pattern. Then press the highlighted letter hint to yank the text in your tmux buffer.

Matched patterns

  • File paths
  • File in diff
  • Git SHAs
  • IPFS CID's
  • Colors in hex
  • Numbers ( 4+ digits )
  • Hex numbers
  • Markdown urls
  • IP4 addresses
  • Docker images
  • kubernetes resources
  • UUIDs

These are the list of matched patterns that will be highlighted by default. If you want to highlight a pattern that is not in this list you can add one or more with --regexp parameter.

Demo

demo

Prerequisites

tmux-thumbs is written in Rust. You will need rustc version 1.35.0 or higher. The recommended way to install Rust is from the official download page.

Tmux integration

Clone the repo:

git clone https://github.com/fcsonline/tmux-thumbs ~/.tmux/plugins/tmux-thumbs

Compile it with cargo:

cd ~/.tmux/plugins/tmux-thumbs
cargo build --release

Source it in your .tmux.conf:

run-shell ~/.tmux/plugins/tmux-thumbs/tmux-thumbs.tmux

Reload TMUX conf by running:

tmux source-file ~/.tmux.conf

Using Tmux Plugin Manager

You can add this line to your list of TPM plugins in .tmux.conf:

set -g @plugin 'fcsonline/tmux-thumbs'

To be able to install the plugin just hit prefix + I. You should now be able to use the plugin!

Configuration

If you want to customize how is shown your tmux-thumbs hints those all available parameters to set your perfect profile.

NOTE: for changes to take effect, you'll need to source again your .tmux.conf file.

@thumbs-key

default: space

Choose which key is used to enter in thumbs mode.

For example:

set -g @thumbs-key F

@thumbs-alphabet

default: qwerty

Choose which set of characters is used to build hints. Review all available alphabets

For example:

set -g @thumbs-alphabet dvorak-homerow

@thumbs-reverse

default: disabled

Choose in which direction you want to assign hints. Useful to get shorter hints closer to the cursor.

For example:

set -g @thumbs-reverse

@thumbs-unique

default: disabled

Choose if you want to assign the same hint for the same matched strings.

For example:

set -g @thumbs-unique

@thumbs-position

default: left

Choose where do you want to show the hint in the matched string. Options (left, right, off_left, off_right).

For example:

set -g @thumbs-position right

@thumbs-regexp-N

Add extra patterns to match. This parameter can have multiple instances.

For example:

set -g @thumbs-regexp-1 '[a-z]+@[a-z]+.com' # Match emails
set -g @thumbs-regexp-2 '[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:' # Match MAC addresses
set -g @thumbs-regexp-3 'Vlan\d+' # match Vlan interface on network devices
set -g @thumbs-regexp-4 "Vlan\\d+" # alternative method of defining regexp
set -g @thumbs-regexp-5 Vlan\\d+ # alternative method of defining regexp

@thumbs-command

default: 'tmux set-buffer {} && tmux display-message \"Copied {}\"'

Choose which command execute when you press a hint. tmux-thumbs will replace {} with the picked hint.

For example:

set -g @thumbs-command 'echo -n {} | pbcopy'

@thumbs-upcase-command

default: 'tmux set-buffer {} && tmux paste-buffer && tmux display-message \"Copied {}\"

Choose which command execute when you press a upcase hint. tmux-thumbs will replace {} with the picked hint.

For example:

set -g @thumbs-upcase-command 'echo -n {} | pbcopy'

@thumbs-bg-color

default: black

Sets the background color for matches

For example:

set -g @thumbs-bg-color blue

@thumbs-fg-color

default: green

Sets the foreground color for matches

For example:

set -g @thumbs-fg-color green

@thumbs-hint-bg-color

default: black

Sets the background color for hints

For example:

set -g @thumbs-hint-bg-color blue

@thumbs-hint-fg-color

default: yellow

Sets the foreground color for hints

For example:

set -g @thumbs-hint-fg-color green

@thumbs-select-fg-color

default: blue

Sets the foreground color for selection

For example:

set -g @thumbs-select-fg-color red

@thumbs-select-bg-color

default: black

Sets the background color for selection

For example:

set -g @thumbs-select-bg-color red

@thumbs-contrast

default: 0

Displays hint character in square brackets for extra visibility.

For example:

set -g @thumbs-contrast 1

@thumbs-osc52

default: 0

If this is set to 1, tmux-thumbs will print a OSC52 copy escape sequence when you select a match, in addition to running the pick command. This sequence, in terminals that support it (e.g. iTerm), allows the content to be copied into the system clipboard in addition to the tmux copy buffer.

For example:

set -g @thumbs-osc52 1

Colors

This is the list of predefined colors:

  • black
  • red
  • green
  • yellow
  • blue
  • magenta
  • cyan
  • white
  • default

There is also support for using hex colors in the form of #RRGGBB.

Alphabets

This is the list of available alphabets:

  • numeric: 1234567890
  • abcd: abcd
  • qwerty: asdfqwerzxcvjklmiuopghtybn
  • qwerty-homerow: asdfjklgh
  • qwerty-left-hand: asdfqwerzcxv
  • qwerty-right-hand: jkluiopmyhn
  • azerty: qsdfazerwxcvjklmuiopghtybn
  • azerty-homerow: qsdfjkmgh
  • azerty-left-hand: qsdfazerwxcv
  • azerty-right-hand: jklmuiophyn
  • qwertz: asdfqweryxcvjkluiopmghtzbn
  • qwertz-homerow: asdfghjkl
  • qwertz-left-hand: asdfqweryxcv
  • qwertz-right-hand: jkluiopmhzn
  • dvorak: aoeuqjkxpyhtnsgcrlmwvzfidb
  • dvorak-homerow: aoeuhtnsid
  • dvorak-left-hand: aoeupqjkyix
  • dvorak-right-hand: htnsgcrlmwvz
  • colemak: arstqwfpzxcvneioluymdhgjbk
  • colemak-homerow: arstneiodh
  • colemak-left-hand: arstqwfpzxcv
  • colemak-right-hand: neioluymjhk

Extra features

  • Arrow navigation: You can use the arrows to move around between all matched items.
  • Auto paste: If your last typed hint character is uppercase, you are going to pick and paste the desired hint.
  • Multi selection: If you run thumb with multi selection mode you will be able to choose multiple hints pressing the desired letter and Space to finalize the selection.

Tmux compatibility

This is the known list of versions of tmux compatible with tmux-thumbs:

Version Compatible
3.0a
2.9a
2.8
2.7
2.6
2.5
2.4
2.3
1.8
1.7

If you can check hat tmux-thumbs is or is not compatible with some specific version of tmux, let me know.

Standalone thumbs

This project started as a tmux plugin but after reviewing it with some friends we decided to explore all the possibilities of decoupling thumbs from tmux. You can install it with a simple command:

cargo install thumbs

And those are all available options:

thumbs 0.5.1
A lightning fast version copy/pasting like vimium/vimperator

USAGE:
    thumbs [FLAGS] [OPTIONS]

FLAGS:
    -c, --contrast    Put square brackets around hint for visibility
    -h, --help        Prints help information
    -m, --multi       Enable multi-selection
    -r, --reverse     Reverse the order for assigned hints
    -u, --unique      Don't show duplicated hints for the same match
    -V, --version     Prints version information

OPTIONS:
    -a, --alphabet <alphabet>                          Sets the alphabet [default: qwerty]
        --bg-color <background_color>                  Sets the background color for matches [default: black]
        --fg-color <foreground_color>                  Sets the foregroud color for matches [default: green]
    -f, --format <format>
            Specifies the out format for the picked hint. (%U: Upcase, %H: Hint) [default: %H]

        --hint-bg-color <hint_background_color>        Sets the background color for hints [default: black]
        --hint-fg-color <hint_foreground_color>        Sets the foregroud color for hints [default: yellow]
    -p, --position <position>                          Hint position [default: left]
    -x, --regexp <regexp>...                           Use this regexp as extra pattern to match
        --select-bg-color <select_background_color>    Sets the background color for selection [default: black]
        --select-fg-color <select_foreground_color>    Sets the foreground color for selection [default: blue]
    -t, --target <target>                              Stores the hint in the specified path

If you want to enjoy terminal hints, you can do things like this without tmux:

> alias pick='thumbs -u -r | xsel --clipboard -i'
> git log | pick

Or multi selection:

> git log | thumbs -m
1df9fa69c8831ac042c6466af81e65402ee2a007
4897dc4ecbd2ac90b17de95e00e9e75bb540e37f

Standalone thumbs has some similarities to FZF.

Background

As I said, this project is based in tmux-fingers. Morantron did an extraordinary job, building all necessary pieces in Bash to achieve the text picker behaviour. He only deserves my gratitude for all the time I have been using tmux-fingers.

During a Fosdem conf, we had the idea to rewrite it to another language. He had these thoughts many times ago but it was hard to start from scratch. So, we decided to start playing with Node.js and react-blessed, but we detected some unacceptable latency when the program booted. We didn't investigate much about this latency.

During those days another alternative appeared, called tmux-picker, implemented in python and reusing many parts from tmux-fingers. It was nice, because it was fast and added original terminal color support.

I was curious to know if this was possible to be written in Rust, and soon I realized that was something doable. The ability to implement tests for all critic parts of the application give you a great confidence about it. On the other hand, Rust has an awesome community that lets you achieve this kind of project in a short period of time.

Roadmap

  • Support multi selection
  • Decouple tmux-thumbs from tmux
  • Code Kitty plugin, now that thumbs can run standalone

Contribute

This project started as a side project to learn Rust, so I'm sure that is full of mistakes and areas to be improve. If you think you can tweak the code to make it better, I'll really appreciate a pull request. ;)

License

MIT

Comments
  • Error building (termbox) on macOS

    Error building (termbox) on macOS

    I am getting the following error when attempting to build this crate on macOS Catalina (10.15.3 (19D76)):

    ❯ env RUST_BACKTRACE=1 cargo build
       Compiling termbox-sys v0.2.11
       Compiling num-traits v0.1.43
       Compiling regex v1.3.1
       Compiling tempfile v3.1.0
       Compiling gag v0.1.10
    error: failed to run custom build command for `termbox-sys v0.2.11`
    
    Caused by:
      process didn't exit successfully: `/Users/jonathan/.tmux/plugins/tmux-thumbs/target/debug/build/termbox-sys-c35f0e040836f872/build-script-build` (exit code: 101)
    --- stdout
    running: "rm" "-rf" ".termbox"
    running: "git" "clone" "https://github.com/nsf/termbox" ".termbox"
    waf configure: setting CFLAGS to: `-m64 -fPIC`
    running: "./waf" "configure" "--prefix=/"
    Setting top to                           : /Users/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/termbox-sys-0.2.11/.termbox 
    Setting out to                           : /Users/jonathan/.cargo/registry/src/github.com-1ecc6299db9ec823/termbox-sys-0.2.11/.termbox/build 
    Checking for 'clang' (C compiler)        : /usr/bin/clang 
    'configure' finished successfully (0.227s)
    
    --- stderr
    Cloning into '.termbox'...
    thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', src/libcore/result.rs:1188:5
    stack backtrace:
       0: std::sys_common::at_exit_imp::push
       1: core::fmt::ArgumentV1::show_usize
       2: std::io::Write::write_fmt
       3: std::panicking::default_hook::{{closure}}
       4: std::panicking::default_hook
       5: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
       6: std::panicking::try::do_call
       7: core::panicking::panic_fmt
                 at src/libcore/panicking.rs:84
       8: core::result::unwrap_failed
                 at src/libcore/result.rs:1188
       9: core::result::Result<T,E>::unwrap
                 at /rustc/5e1a799842ba6ed4a57e91f7ab9435947482f7d8/src/libcore/result.rs:956
      10: build_script_build::run
                 at ./build.rs:88
      11: build_script_build::configure
                 at ./build.rs:58
      12: build_script_build::main
                 at ./build.rs:11
      13: std::rt::lang_start::{{closure}}
      14: std::panicking::try::do_call
      15: panic_unwind::dwarf::eh::read_encoded_pointer
      16: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
      17: std::rt::lang_start
      18: build_script_build::run
    note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
    
    warning: build failed, waiting for other jobs to finish...
    error: build failed
    
    opened by jrop 22
  • Fix OSC52

    Fix OSC52

    to fix #54 once solution for tmux/tmux#2363 gets merged this should be merged too.

    I decided to make use of the now empty fn send_osc52()

    change to pane_command is result of formatter

    opened by pbartyik 18
  • Adds OSC52 copy escape sequence support

    Adds OSC52 copy escape sequence support

    Currently I can only get the copied content in the tmux copy buffer, not in the system clipboard. This commit adds an option to print the copied text as a OSC52 copy escape sequence, which in supported terminals (tested in iTerm) will be copied to the system clipboard.

    enhancement 
    opened by isundaylee 18
  • Tmux Plugin is too slow

    Tmux Plugin is too slow

    Hi there, awesome plugin, very productive one. Thanks for the job done here very appreciated. I found that tmux plugin is really slow in compare with the standalone thumb, it takes up to 10 secs to find all occurs, I was wondering how can I troubleshoot this, just to see if I can somehow improve it.

    opened by MushiTheMoshi 13
  • uppercase-command only print partial results

    uppercase-command only print partial results

    Example output on screen:

    /home/peter/test
    

    activating tmux-thumbs show hint at the beginning of the path and selecting it will copy the whole path to the clipboard. But when using uppercase hint, only the part /home/ is printed to the console

    opened by pengux 11
  • Error with tmux-thumbs.sh on OpenBSD

    Error with tmux-thumbs.sh on OpenBSD

    On OpenBSD 7.0, I have an error when I try to use the plugin : '~/.tmux/plugins/tmux-thumbs/tmux-thumbs.sh' returned 1

    After some debug, I fix this issue by modifying the regexp used for grep to get VERSION :

    VERSION=$(grep 'version =' "${CURRENT_DIR}/Cargo.toml" | grep -oE "[0-9]+\.[0-9]+\.[0-9]+")

    Could you commit this fix please ?

    opened by lcheylus 10
  • upcase-command doesn't work for user regexp

    upcase-command doesn't work for user regexp

    when this regexp is added set -g @thumbs-regexp-1 '-?-[a-zA-Z0-9_]+' # options running thumbs highlights the matches and the default matches, ie SHAs.

    uppercase command works for the SHAs but not for the user defined regexp weirdly the dash '-' also matches tilde '~'

    opened by nkh 10
  • Selection is broken in WSL

    Selection is broken in WSL

    Under Windows Subsystem for Linux (running Ubuntu 18), tmux-thumbs hangs when trying to select something.

    Repo'd on WSL Terminal, cmder, and the Ubuntu App that WSL ships with. Seems to be unrelated to term emus.

    I can hit Enter which changes the prefix/suffix marking of a url or whatever. But once I start pressing keys to select on, the pane freezes. Tmux still responds. I can create a new window and see the tmux-thumbs process running [...]/.tmux/plugins/tmux-thumbs/target/release/tmux-thumbs --unique --tmux-pane %34.

    Maybe related, but when there are multiple panes on the window, it breaks the pane out in an unexpected way.

    I'll try to follow up with more testing using a bare tmux.conf and just tmux-thumbs. There are a couple of small differences in my tmux.conf WSL vs my native linux one (where it works wonderfully).

    opened by sherrman 10
  • Showing only single alphabet hints intermittently

    Showing only single alphabet hints intermittently

    Hi,

    Sometimes it shows only single alphabet hints

    image

    The screenshot above shows that it works fine but randomly, it shows like blow.

    image

    As you can see, it scrolls up a bit and shows only single alphabets.

    Please let me know if you need logs or something

    Many thanks

    bug wontfix 
    opened by penguininthedesert 9
  • fix regexp parsing from tmux config

    fix regexp parsing from tmux config

    This is to address #56 Alright, here is the problem. \w+ does not match \\ [, etc. Also it can be a valid requirement to match ", so it is just easier to treat whatever comes after set -g @thumbs-regexp-N as the regexp that needs matching.

    When not using any quotes or using double quotes, the user needs to define regexp with \\, when using single quotes, single \ gets the job done.

    In this case a regexp would look something like this:

    set -g @thumbs-regexp-1 "Vlan\\d+"
    

    or

    set -g @thumbs-regexp-1 'Vlan\d+'
    

    or without quotes

    set -g @thumbs-regexp-1 Vlan\\d+
    

    When this gets passed to tmux-thumbs it'll read as Vlan\\d+ which'll get passed to thumbs as Vlan\\\\d+ thus it needs to be replaced.

    opened by pbartyik 8
  • Feature request :: tmux popup integration

    Feature request :: tmux popup integration

    opened by lcrockett 8
  • Default options for CLI commands (update/install)

    Default options for CLI commands (update/install)

    I automate most of my dotfiles including updating them and everytime I update tmux I have to see the tmux-thumbs screen and always press option 1 (compile).

    It would be nice if this CLI command could accept a default option.

    something like

    ./tmux-thumbs-install.sh update --compile
    

    or

    ./tmux-thumbs-install.sh update --download
    

    This would make the update process silent and just compile without always having to ask if we want to update or not.

    opened by dagadbm 3
  • Matched strings get displaced when preceded by multi-byte utf8 chars

    Matched strings get displaced when preceded by multi-byte utf8 chars

    Like the title and [screenshot](https://i.imgur.com/Fd2DRbp.png suggests, matched text gets displaced when some multi-byte char(s) is(are) present in the line containg the match. As you can see from the screenshot, the same string is matched on the prompt line and the output line, but only the former is displaced. Here the arrow character at the end of the prompt is multi-byte, perhaps the "unticked box" char as well. Anyways, every time a multi-byte char is present on a line, this happens.

    My wild guess would be some computation error in the match index. I've tried looking at the code, but unfortunately, I don't speak rust at all.

    Let me know if this would be something that would warrant a fix.

    opened by zenfailure 2
  • Workaround startup lag by temporarily disabling tmux activity monitoring and visual effects.

    Workaround startup lag by temporarily disabling tmux activity monitoring and visual effects.

    This change addresses: Tmux Plugin is too slow · Issue #88 · fcsonline/tmux-thumbs.

    tmux-thumbs.sh now temporarily alters the following tmux options for a single pane:

    • monitor-activity
    • visual-activity
    • visual-bell
    • visual-silence

    The global options are untouched to prevent race conditions between concurrent script invocations.

    opened by hiaky 0
  • Add tmux note to keybinding for list-keys

    Add tmux note to keybinding for list-keys

    This PR simply adds a -N note so that the chosen key binding appears in tmux list-keys / <prefix> + ? and "Describe key binding" <prefix> + /, which is useful when you have a lot of custom keybindings.

    opened by eggbean 0
  • Trigger specific regex with custom key

    Trigger specific regex with custom key

    Thank you for this great plugin.

    I apologize if this has already been implemented, but I can't find how to trigger specific regexes (e.g. @thumbs-regexp-2 '[0-9]{3,}') with an additional key as opposed to triggering all of them with the default key.

    If this is not possible at the moment, then maybe this could be considered as a feature request ;)

    opened by r-31415 2
Releases(0.7.1)
Owner
Ferran Basora
We need a tool™
Ferran Basora
Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.

Membrane is an opinionated crate that generates a Dart package from a Rust library. Extremely fast performance with strict typing and zero copy returns over the FFI boundary via bincode.

Jerel Unruh 70 Dec 13, 2022
A Rust library that implements the main lightning logic of the lipa wallet app.

lipa-lightning-lib (3L) Warning This library is not production ready yet. Build Test Start Nigiri Bitcoin: nigiri start --ln The --ln flag is not stri

lipa 9 Dec 15, 2022
📮 load, write, and copy remote and local assets

axoasset This library offers read, write, and copy functions, for local and remote assets given a string that contains a relative or absolute local pa

axo 7 Jan 25, 2023
Bongo Copy Cat wants to be involved in everything you do but instead just imitates you hitting your keyboard all day. After all it's just a cat.

Bongo Copy Cat Introduction Bongo Copy Cat wants to be involved in everything you do but instead just imitates you hitting your keyboard all day. Afte

Abhijeet Singh 4 Jan 23, 2023
One copy of Electron to rule them all.

chroma One copy of Electron to rule them all. chroma keeps a central, up-to-date version of Electron, and makes all your installed Electron apps use i

Gergő Móricz 12 Mar 20, 2023
Verbump - A simple utility written in rust to bump and manage git semantic version tags.

Verbump - A simple utility written in rust to bump and manage git semantic version tags.

Sarat Chandra 6 May 6, 2022
Rust version of tomnomnom/waybackurls

wayback-rs Rust version of tomnomnom/waybackurls Command line interface for fetching url from Wayback Machine, CommonCrawl, VirusTotal.

null 3 Oct 22, 2021
Convert Hygea calendar to an iCal file to easily import it to Google Calendar (Rust version)

Hygea to iCal Goal Hygea provides a calendar via PDF and an application called Recycle. I just wanted to use an iCal file to import it in my calendar.

Guillaume Quittet 2 Oct 28, 2021
A rust-based version of the popular dnsgen python utility

ripgen A rust-based version of the popular dnsgen python utility. ripgen is split into two main parts: ripgen: A CLI utility that calls into ripgen_li

resync 198 Jan 2, 2023
The tool like Browserslist, but written in Rust.

browserslist-rs The tool like Browserslist, but written in Rust. Try it out Before trying this crate, you're required to get Rust installed. Then, clo

Pig Fang 76 Nov 29, 2022
A Polkadot SDK-like state machine written from scratch in Rust.

Rust State Machine This repository is the basis for a tutorial teaching how to develop a simple state machine using Rust. Goal The goal of this tutori

Shawn Tabrizi 10 Nov 29, 2023
A simplified but faster version of Routerify

Routerify lite Routerify-lite is a simplified but faster version of Routerify. It only provides below functions: path matching error handling Why not

jinhua luo 7 Dec 30, 2022
🦸‍♂️ Recast migrates your old extensions to AndroidX, making them compatible with the latest version of Kodular.

Recast Recast helps make your old extensions compatible with Kodular Creator version 1.5.0 or above. Prerequisites To use Recast, you need to have Jav

Shreyash Saitwal 13 Dec 28, 2022
Incremental, multi-version remote backup tool for block devices.

bsync Incremental, multi-version remote backup tool for block devices. The on-disk backup format is a SQLite database and I've been dogfooding this on

Heyang Zhou 7 Aug 21, 2022
Wrapped ICP (WICP) - A composable and interoperable wrapped version of ICP.

Wrapped ICP - WICP Wrapped ICP (WICP) is a wrapped version of the IC's native token, ICP. Each WICP will be backed 1:1 with ICP, meaning that 1 WICP w

Psychedelic 16 Sep 23, 2022
Ferris has to escape the creepers using a modified version of Dijkstra called A*

Ferris has to escape the creepers using a modified version of Dijkstra called A*

Security Union 13 Oct 30, 2022
A future version of Pokétwo

poketwo-next Pokétwo brings the Pokémon experience to Discord. Catch randomly-spawning pokémon in your servers, trade them to expand your collection,

Pokétwo 13 Aug 20, 2022
Rc version `tokio-rs/bytes`

RcBytes The aim for this crate is to implement a Rc version bytes, which means that the structs in this crate does not implement the Sync and Send. Th

Al Liu 2 Aug 1, 2022
Original Version Management System based on Git

nss (noshishi) Original Version Management System based on Git. Learning git and rust for good developer. Usage Install cargo install nssi how to nss

nopeNoshishi 4 Feb 13, 2023