GithubHelp home page GithubHelp logo

laktak / extrakto Goto Github PK

View Code? Open in Web Editor NEW
844.0 13.0 45.0 221 KB

extrakto for tmux - quickly select, copy/insert/complete text without a mouse

License: MIT License

Python 92.93% Shell 7.07%
tmux extract complete autocomplete copy-paste clipboard completion

extrakto's Introduction

extrakto for tmux

intro

Output completions - you can complete commands that require you to retype text that is already on the screen. This works everywhere, even in remote ssh sessions.

You can fuzzy find your text instead of selecting it by hand:

  • press tmux prefix + tab to start extrakto
  • fuzzy find the text/path/url/line
  • use custom filters (ctrl + f)
  • press
    • tab to insert it to the current pane,
    • enter to copy it to the clipboard,
  • see other features in HELP (press ctrl-h in extrakto)

Use it for paths, URLs, options from a man page, git hashes, docker container names, ...

Requirements

clippy

  • tmux - popups require 3.2, otherwise extrakto will open in a split window.
  • fzf
  • Python 3.6+
  • a posix shell like Bash

Supported clipboards:

  • Linux Xorg (xclip) and Wayland (wl-copy)
  • macOS (pbcopy)
  • WSL
  • bring your own, see the Wiki for examples (like termux)

Installation with Tmux Plugin Manager

Add the plugin to the list of TPM plugins in .tmux.conf:

set -g @plugin 'laktak/extrakto'

Hit prefix + I to fetch the plugin and source it. You can use prefix + U to update all plugins.

You should now have all extrakto key bindings defined.

Manual Installation

Clone the repo:

$ git clone https://github.com/laktak/extrakto ~/clone/path

Add this line to the bottom of .tmux.conf:

run-shell ~/clone/path/extrakto.tmux

Reload the tmux environment:

# type this in terminal
$ tmux source-file ~/.tmux.conf

You should now have all extrakto key bindings defined.

Wiki

Add or look for special tips in our wiki.

Options

You can set any of these options by adding them to your ~/.tmux.conf file:

set -g <option> "<value>"

Where <option> and <value> correspond to one of the options specified below

Common Options

Option Default Description
@extrakto_grab_area window full Whether you want extrakto to grab data from the recent area, the full pane, all current window's (window recent) areas or all current window's (window full) panes. You can also set this option to any number you want (or number preceded by "window ", e.g. "window 500"), this allows you to grab a smaller amount of data from the pane(s) than the pane's limit. For instance, you may have a really big limit for tmux history but using the same limit may end up on having slow performance on Extrakto.
@extrakto_filter_order word all line Filter modes order. The first listed mode will be the default when opening extrakto. You may use word, line, path, url, quote, s-quote or any of your own filters separated by a space. all applies all filters at the same time.

Keys

Option Default Description
@extrakto_key tab The key binding to start. If you have any special requirements (like a custom key table) set this to 'none'. See "Custom Tmux Keybindings".
@extrakto_copy_key enter Key to copy selection to clipboard.
@extrakto_insert_key tab Key to insert selection.
@extrakto_filter_key ctrl-f Key to toggle filter mode.
@extrakto_grab_key ctrl-g Key to toggle grab mode.
@extrakto_edit_key ctrl-e Key to run the editor.
@extrakto_open_key ctrl-o Key to run the open command.

All but @extrakto_key are controlled by fzf and must follow its conventions.

Advanced Options

Option Default Description
@extrakto_clip_tool_run bg Set this to tmux_osc52 to enable remote clipboard support or fg/bg to have your clipboard tool run in a foreground/background shell.
@extrakto_clip_tool auto Set this to whatever clipboard tool you would like extrakto to use to copy data into your clipboard. auto will try to choose the correct clipboard for your platform.
@extrakto_editor This defaults to $EDITOR if not set.
@extrakto_fzf_layout default Control the fzf layout which is "bottom-up" by default. If you prefer "top-down" layout instead set this to reverse. In fact, this value is passed to the fzf --layout parameter. Possible values are: default, reverse and reverse-list
@extrakto_fzf_tool fzf Set this to path of fzf if it can't be found in your PATH.
@extrakto_fzf_header i c o e f g h Define the fzf header to show keys for insert, copy, open, edit, filter, grab and help. You can reorder or omit information you don't need.
@extrakto_fzf_unset_default_opts true Unsets custom FZF_DEFAULT_OPTS as it can potentially cause problems in extrakto operations
@extrakto_open_tool auto Set this to path of your own tool or auto to use your platforms open implementation.
@extrakto_popup_position C Set position of the tmux popup window. Possible values are in the display-popup entry in man tmux. Set this to x,y to set the x and y positions to x and y respectively.
@extrakto_popup_size 90% Set width and height of the tmux popup window. Set this to w,h to set the width to w and height to h.
@extrakto_split_direction a Whether the tmux split will be auto, popup, vertical or horizontal
@extrakto_split_size 7 The size of the tmux split (for vertical/horizontal)

Examples

set -g @extrakto_split_size "15"
set -g @extrakto_clip_tool "xsel --input --clipboard" # works better for nvim
set -g @extrakto_copy_key "tab"      # use tab to copy to clipboard
set -g @extrakto_insert_key "enter"  # use enter to insert selection
set -g @extrakto_fzf_unset_default_opts "false"  # keep our custom FZF_DEFAULT_OPTS
set -g @extrakto_fzf_header "i c f g" # for small screens shorten the fzf header

Custom Tmux Keybindings

Instead of using @extrakto_key you can define your own key binding to start extrakto in your .tmux.conf:

tmux bind-key YOUR-KEY run-shell "~/.tmux/plugins/extrakto/scripts/open.sh \"#{pane_id}\""

If you wish you can also define different keys to start with a specific filter:

tmux bind-key YOUR-KEY run-shell "~/.tmux/plugins/extrakto/scripts/open.sh \"#{pane_id}\" FILTER-NAME"

Custom Filters

You can define your own filters by creating a file in ~/.config/extrakto/extrakto.conf:

[quote]
regex: ("[^"\n\r]+")

To override an existing filter copy it to your file first.

If you want to remove one of the alternate filters you can set it to None:

[quote]
alt2: None

See extrakto.conf for syntax and predefined filters.


CLI

You can also use extrakto as a standalone tool to extract tokens from text.

Installation

For now simply clone the repository and link to the tool somewhere in your path:

git clone https://github.com/laktak/extrakto
cd extrakto
# assuming you `export PATH=$PATH:~/.local/bin` in your `.bashrc`:
ln -s $PWD/extrakto.py ~/.local/bin/extrakto

Requires Python 3.6+.

CLI Usage

usage: extrakto.py [-h] [--name] [-w] [-l] [--all] [-a ADD] [-p] [-u] [--alt] [-r] [-m MIN_LENGTH] [--warn-empty]

Extracts tokens from plaintext.

optional arguments:
  -h, --help            show this help message and exit
  --name                prefix filter name in the output
  -w, --words           extract "word" tokens
  -l, --lines           extract lines
  --all                 extract using all filters defined in extrakto.conf
  -a ADD, --add ADD     add custom filter
  -p, --paths           short for -a=path
  -u, --urls            short for -a=url
  --alt                 return alternate variants for each match (e.g. https://example.com and example.com)
  -r, --reverse         reverse output
  -m MIN_LENGTH, --min-length MIN_LENGTH
                        minimum token length
  --warn-empty          warn if result is empty

Contributions

Thanks go to all contributors for their ideas and PRs!

If you make a PR, please keep it small so that it's easier to test and review. Try to create one PR per feature/bug.

Please run black if you change any python code and run shfmt -p if you change any shell files.

extrakto's People

Contributors

anuvyklack avatar atomicstack avatar benoit-pierre avatar carlocab avatar disser avatar edwinclement08 avatar hegga avatar iloveitaly avatar ivanalejandro0 avatar jackielii avatar jediahkatz avatar laktak avatar lukaspietzschmann avatar lyjdwh avatar marcdeop avatar marwan-tanager avatar maximbaz avatar nhatanh002 avatar pylipp avatar romhml avatar sturob avatar systemmonkey42 avatar vekkt0r avatar wvaviator avatar x4121 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

extrakto's Issues

Suggestion for setting @extrakto_key to '' does not work.

The key binding to start. If you have any special requirements (like a custom key table) set this to '' and define a binding in your .tmux.conf. See extrakto.tmux for a sample.

This does not work as described.

The only workaround I've found is to unbind the key afterwards, which is too late as its already removed my existing tab binding.

Hide the total number of lines counter

How about hiding the total number of lines counter? It occupies one extra line, and not very useful in my opinion. It is possible with fzf --no-info key.

Insert/copy not working on Apple M1

Hello, first of all, I love this plugin, thanks for the awesome job!
I just got a MacBook Air M1, and after setting up tmux I was not being able to copy/insert the results that show up. I already tried to use the HEAD version of tmux as described in this README but I got the same behavior.

The plugin looks like it's working, everything show up as normal, it's only when I select the value from the list by hitting Tab or Enter that nothing happens. My clipboard remains untouched with the previous text I've selected in the past.

I do have [email protected] running and the Terminal.app is running under Rosetta 2, and I've tested the pbcopy command separately and it does work.

Just a side note: when using Vim, I had problems with ultisnips throwing python errors almost every time I entered in INSERT mode; I'm still not sure what was and my only solution was to remove the plugin for now.

EDIT: just to add to my side note, I've installed my dev env a few times on linux in the past months using this plugin and I never had a problem before, it always worked!
EDIT2: I'm using zsh, not bash :)
Any suggestions on what should I do? Thanks!

Add option for different content grabbing behavior

Extrakto gets its data from the whole pane, and a user may want to get it only from the visible area.

This has been discussed here: #4, #7 (comment)

I think that instead of adding a config option for "how many lines you want to grab" it may be easier to grasp for a user to pick different presets, like: "grab from all the contents" or "grab only from visible area".

Proposed option name: @extrakto_grab_from (or maybe @extrakto_grab_size)
Options: visible, all
Default: I think that all for default makes more sense, since fzf is really fast and I think that trying to grab something from the screen that just got pushed out of sight is a pretty common case.

If #7 gets approved, we'll have horizontal and vertical window for extrakto and the "visible area" will need to be handled differently.

Grabbing from the visible area will require to capture with -S X being X the vertical lines of the extrakto pane, or 0 if we are displaying it horizontally.

OSC 52 Issue

Hi!

Thanks for an excellent tmux plugin! I use this extensively every day. However, at the moment I am trying to transition to using OSC 52 for remote copying over SSH.

I use the Kitty terminal, and I have the following in my kitty.conf:

clipboard_control   write-clipboard write-primary no-append

I have also created a osc52.sh which looks like this:

#!/bin/bash
date >> ~/osc52.log
printf "\033]52;c;$(base64 | tr -d '\r\n')\a"

The date line is just there for logging purposes so that I know when the script has been executed.

Executing the script like shown below works as a charm and copies the text to my local clipboard over a SSH connection (inside of a tmux session):

echo testing | osc52.sh

My extrakto config looks like this:

set -g @extrakto_clip_tool_run "fg"
set -g @extrakto_clip_tool "osc52.sh"
set -g @extrakto_popup_size "68%,32%"

However, if I invoke extrakto by pressing prefix+Tab, selecting the desired text, I seem to end up in a copy/view mode which does not display anything. The logfile of the script shows that is has been run, but nothing has been copied to my clipboard. Can you think of any reason why this is not working?

Thanks again for a excellent piece of software, it really meets my needs.

Idea: one key binding to rule them all (well, two)

Instead of having type Prefix, Shift+X, u/U/p/P, how about the following:

Typing just Prefix, Shift+X opens a fzf with all potential candidates: files, urls, paths, whatever. It is so easy to filter in fzf, that I think it is an overkill to have different modes.

We could have just two shortcuts:

  • Prefix, x - to find anything (files, urls, paths) and copy it to clipboard
  • Prefix, Shift+X - to find anything and paste it directly to the terminal

No need to write one single super-complex regex, let's have multiple regexes (one for urls, one for paths, etc.) and just run them all one by one, and combine their results in fzf window.

Multiple results (similar to `fzf --multi`)

This is a feature request to support choosing multiple results. The multiple results should be separated by spaces. Currently extrakto allows only one result per invocation.

Steps to reproduce

  1. in ~/.tmux.conf add
    set -g @extrakto_fzf_tool "/path/to/fzf --multi"
    set -g @extrakto_insert_key 'enter'
    
  2. enter a tmux session with extrakto enabled
  3. run : hello world
  4. trigger extrakto
  5. in the extrakto window, move cursor to hello
  6. press <tab> to select
  7. move cursor to world
  8. press <tab> to select
  9. press <enter>to insert

Expected result

Extrakto inserts hello world at cursor position.

Actual result

Extrakto inserts world at cursor position.

Info

  • extrakto version: f74ec23
  • fzf version: 0.19.0 (9a41fd5)
  • tmux version: tmux 3.2a
  • python version: Python 3.9.2
  • bash version: 5.1.8(1)-release

Rationale

One of the most common use cases of extrakto is to "retype" file paths. Often users would like to edit several files at a time. For example, after user runs git status and sees several files, they might want to edit three of the listed files. Currently user has to trigger extrakto three times to achieve this.

Feature request: open

Loving this plugin. I wish, besides providing insertion and copy, that it provided open. It would work for files, URLs etc. There could be a simple configuration for the opening command, for example, for me, simply setting up gio open <text selection> as the command would work for most files and URLs.

word filter should split on commas

word filter currently doesn't split on commas. Eg if there is line like users:(("node",pid=1454441,fd=22)), then word filter would extract 1454441,fd; would expect those 2 values to be split on comma.

Remote Copy via OSC52 setup assistance

Hi there,

I can not get the remote copy feature to work via the extrakto interface and can not figure out why.

Following the instructions here

  • On the remote machine which I have ssh'd into I created a file called osc52 and pasted the below bash script in it.
#!/bin/bash
printf "\033]52;c;$(base64 | tr -d '\r\n')\a"
  • Moved it to ~/.local/bin
  • Made sure it is executable. chmod +x osc52
  • the example test works as intended and I do see the hello text in my local clipboard.
  • I do have the below lines in my tmux.conf on my local machine
set -g set-clipboard on
set -g @extrakto_clip_tool_run "fg"
set -g @extrakto_clip_tool "osc52"

I can confirm that the pop up window does have the ssh'd contents, but when hitting enter to copy text, nothing appears in my local clipboard. The Tab to Insert feature does work though!

Honestly, I have never heard of osc52 until today and even google'd it thinking I was doing something wrong. Even came across an article saying that for osc52 to work the terminal itself must support it. I luckily use Alacritty which supports osc52 based on the article.

Since I can copy to my local clipboard from the remote machine using echo hello | osc52 , I am assuming it has something to do with my tmux.conf?

How to make the default filter as "lines" ?

Hello,

In my tmux conf, I had this line to make the default filter as "lines":

set -g @extrakto_default_opt "lines"

I updated the plugin and now this setting does not work anymore.

In the documentation it is said that this option has been removed in favor of the "new filter mode":
image

But I don't really understand what is this new filter mode.

How can I make "lines" as the default filter mode with the new version (git tag is de8ac3e) ?

One key to both insert and copy

It'd be nice to have the ability to have one key do both inserting and copying.

Assigning extrakto_copy_key and extracto_insert_key to the same key doesn't work.

The easiest solution imo is to add extrakto_copy_insert_key that does both copying and inserting.

Let me know if you're not opposed to the idea, I'd happily submit a pr...

Key binding is broken

Hi it's really great plugin that I always imagine. Thanks!

But I found on current head(6d953e7), no key is working now.

When I enter "enter, tab, etc", nothing happened and tmux pane is disappear silently.

Although I did not bisect exact commit, I confirmed that
afc7df1 is working as expected and suspect there's something wrong between the commits.

My env

  • tmux 3.1b
  • zsh 5.7.1
  • osx catalina

Thanks.

Error on ESC after typing some text

On typing some text and pressing ESC for giving up I'm getting:

error: unable to extract - check/report errors above
You can also set the fzf path in options (see readme).

Feature request :: tmux popups

Any chance it will be expanded in the future to support tmux's (+3.2) new popup functonality ? It would be nice if instead of an additional pane, the results of extrakto would open in a separate popup.

See also other resources related to this feature:

I've tried playing around with a alternative key binding to see if I could get it working:
bind-key A display-popup -d '#{pane_current_path}' -E -K -R "$HOME/.tmux/plugins/extrakto/scripts/tmux-extrakto.sh" -h 90% -w 90% -yC -xC

This works to some degree, however it looks like it has issues pulling the contents of the current pane. That can possible be reproduced by repeatedly hitting ctrl-g while within the popup window. You'll be able to see the error popup in the background: can't find pane !

By any chance, is there any popup 'roadmap' ?

Support skim?

Is it possible to use an alternate search tool such as skim instead of fzf?

I tried setting

@extrakto_fzf_tool "sk"

but, I believe it has slightly different configuration options.

Using tmux pane as the split mechanism is problematic

A typical thing I do is have a number of splits in a pane, zoom (prefix + z) into a split and do stuff. Using extrakto in this context takes you out of the zoom and makes the pane (understandably) revert to the unzoomed view.

It may be that there's nothing to do about this. which I suppose is fine because I can't think of a direct way to fix this; just figured I'd mention it in case something came to mind

Quiting fzf with <c-d> yields error message.

This error message seems to be meant for when fzf is not installed, not for when fzf exists with a non-zero exit code. I'm used to to close fzf and would like it to work just like if was pressed.

error: unable to extract - check/report errors above
You can also set the fzf path in options (see readme)

to reproduce for me.
with a very sparse tmux.conf

set-option -g prefix C-Space

set -g @plugin 'laktak/extrakto'

run '~/.tmux/plugins/tpm/tpm'

Fetch content prior to opening split

As-is:
Upon launching extrakto (prefix+Tab), a split-pane is opened, in the bottom by default.
The contents this new split is covering in the pane will be excluded from the result.

To-be:
Fetch the contents into the script before opening the extrakto split, so the contents this new split covers would be included in results.

Feature request: open with $EDITOR

This request is quite similar to #15 and comes from https://github.com/tmux-plugins/tmux-open.
The idea is to split between "I want to open this folder/URL/file in the system default" and "I want to edit this file in $EDITOR inside tmux".

Would this feature be of interest/accepted? What would be an appropriate keybinding (tmux-open used 'o' for xdg-open and 'ctrl-o' for $EDITOR), maybe 'ctrl-shift-o'?

Thanks in advance, already love this plugin :)

the split disappears immediately

When I trigger extractor I can see the split at the bottom of the terminal for a split second, but then it disappears without a possibility of selecting the snippet.

Not sure what kind of additional information could be useful ...

xclip error on Enter (xclip)

Testing your plugin I found a problem when wanting to add the text to the cipboard (xclip).
A separate test shows

echo "tst" | xclip -i -selection clipboard
Error: Can't open display: (null)

Maybe this
can be handled within extracto.

Create Extrakto screencast

Other tmux plugins (tmux-yank, tmux-copycat) have screencasts that catches people's attention into using them.

It would be really nice to have something like that for Extrakto.

And (maybe to be handled as a different issue) we could consider having some short gifs to quickly show potential users how cool Extrakto is :)

extrakto.py invalid syntax

a@vdi:~/.tmux/plugins/extrakto$ ./extrakto.py
  File "./extrakto.py", line 49
    key = f"alt{i}"
                  ^
SyntaxError: invalid syntax

a@vdi:~/.tmux/plugins/extrakto$ bash --version
GNU bash, version 5.1.0(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

a@vdi:~/.tmux/plugins/extrakto$ python --version
Python 3.6.13

Improve clipboard functionality

We should extract the clipboard functionality into a separate script, which will allow us to have a better contained solution for clipboard handling. That will make it easier to have support for more platforms/apps.

I have a clipboard script that I often use that we could use as inspiration: https://gist.github.com/ivanalejandro0/fc918ddce0df882c7ad70b134da4a5b3

We can also get some ideas from tmux-yank's clipboard_copy_command function: https://github.com/tmux-plugins/tmux-yank/blob/master/scripts/helpers.sh#L116

Conditional Key Binding

Im trying to do a conditional keybinding like this:

is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
    | grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|n?vim?x?)(diff)?$'"

tmux bind-key -n M-f if-shell "$is_vim" "send-keys M-f" "run-shell '$extrakto_open \"#{pane_id}\"'"

I was wondering if theres a way to configure this so I can set this key-binding in my regular tmux.conf?

Right now I have to modify the actual extrakto.tmux file

Exits with error

Neat plugin! I like anything that interops with fzf.

If I open this plugin's fzf window and change my mind, hit Ctrl-C, the window remains open with an error message.

error: unable to extract - check/report errors above
You can also set the fzf path in options (see readme).

There are no errors "above." This is not an error situation. I just don't want to extract anything.

Workaround isn't too bad, but it's an extra keypress: press Enter, and the error window closes.

Wonderful plugin, over come remain-on-exit?

I wish I knew of this tmux plugin earlier. Fantastic work! I will be advertising this for you where I can make the suggestion. :)

My co worker is all standard stuff, I think this is going to be the one plugin I can get him to install. so much easier the grabbing the mouse to copy and paste something that is to long or complicated to type.

Support request:
I use the dead pane option in tmux, it keeps ssh failures or disconnects from closing a window so I know that it disconnected. Is there an option that I can set to force the dead pane closed when using your amazing plugin.

Tmux 3.1b
bind-key R respawn-pane
set-option -g remain-on-exit on

is what I have for the window to stay open, and it allows me to reconnect to a server. It also keeps the extrakto window pane open after using it but would like it to close out if possible. Thank you so much for your time.

Can't edit when not in a shell

Context: cant edit filepath in editor when extract token from tmux pane with neovim
What happened:

  • open tmux
  • open file file_with_path.txt with filepath in tmux with neovim
  • press prefix+tab (call extrakto)
  • select filepath, press ctrl+e
  • filepath doesnt open in editor, but text is selected in neovim in file_with_path.txt buffer

What expected: open ~/.tmux.conf in editor
Reproduction steps:

$ tmux
$ # add filepath, for example ~/.tmux.conf
$ echo '~/.tmux.conf' > /tmp/file_with_path.txt
$ # open neovim and press ctrl+tab, "tmux", ctrl+e
$ nvim /tmp/file_with_path.txt

Completion mode

It would be nice to be able to use extrakto to complete the word the command line.

For example, if I have on the command line:

> git add src/t

If, at this time, I hit prefix + tab, I would like for extrakto to start the fzf with src/t. At this point, I should be able to continue typing or event modify the command. Once I select the line I want, I should be able to hit tab and it will replace word on the command-line.

respect FZF_DEFAULT_OPTS

I find this one tricky.

I have my colour scheme for FZF stored in FZF_DEFAULT_OPTS. It's synced with base16-shell so I can have one command to switch the colour scheme for the terminal, vim & FZF.

However when I tried to configure extrakto with:

set -g @extrakto_fzf_tool "$HOME/.fzf/bin/fzf $FZF_DEFAULT_OPTS"

It just didn't work. After some digging I realised I started tmux directly with a keybinding in i3. So that must have skipped my .zshrc eval because it's done after tmux is started?

anyway, I find that the easiest way for me to hack this is just to add $FZF_DEFAULT_OPTS when launching the $fzf_tool in https://github.com/laktak/extrakto/blob/master/scripts/extrakto.sh#L164

Any better suggestions?

Path matched terminate on a space, even if the space is escaped.

When matching a path, shell completion will often result in escaped spaces (in preference to quotes)
eg

# ls '/export/datastore/Images/Windows Server/en_window_server_version_20h2_x64_dvd_a<press tab for completion>
# ls /export/datastore/Images/Windows\ Server/en_window_server_version_20h2_x64_dvd_a932282f.iso <expanded result>
/export/datastore/Images/Windows Server/en_window_server_version_20h2_x64_dvd_a932282f.iso

Extracto completion will give me
/export/datastore/Images/Windows\
and
Server/en_window_server_version_20h2_x64_dvd_a932282f.iso
as two separate choices.

Can the function to idenfifying paths keep escaped spaces? Possibly giving a choice of original escaped path, quoted path, or just the path (just as it does when identifying a quoted string)?

Thanks

UnicodeDecodeError on start sometimes when using fzf & delta

I was using fzf & delta to view the git history graph of eclipse.jdt.ls and bumped into the following exception:

Traceback (most recent call last):
  File "/Users/frederick/.tmux/plugins/extrakto/scripts/../extrakto.py", line 208, in <module>
    main(parser)
  File "/Users/frederick/.tmux/plugins/extrakto/scripts/../extrakto.py", line 141, in main
    text = sys.stdin.read()
  File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 513: invalid start byte

So I modified the code to the following and reproduced the case:

    text = None
    try:
        text = sys.stdin.read()
    except UnicodeDecodeError as e:
        f = open('/tmp/extrakto.bin', 'w+b')
        f.write(e.object)
        f.close()
        raise e
File "/Users/frederick/.tmux/plugins/extrakto/scripts/../extrakto.py", line 215, in <module>
  main(parser)
File "/Users/frederick/.tmux/plugins/extrakto/scripts/../extrakto.py", line 148, in main
  raise e
File "/Users/frederick/.tmux/plugins/extrakto/scripts/../extrakto.py", line 143, in main
  text = sys.stdin.read()
File "/usr/local/Cellar/[email protected]/3.9.5/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
  UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 15361: invalid start byte

(15361 is 0x3c01 btw)

00003b10: 2020 2020 2020 2020 2020 2020 20e2 9482               ...
00003b20: 0a20 202a 2066 3135 6438 6135 204a 696e  .  * f15d8a5 Jin
00003b30: 626f 2057 616e 6720 4164 6420 6665 6174  bo Wang Add feat
00003b40: 7572 653a 2061 7574 6f6d 6174 6963 2073  ure: automatic s
00003b50: 6f75 7263 6520 7265 736f 6c75 7469 6f6e  ource resolution
00003b60: 2066 6f72 2063 6c61 7373 6573 2069 6e20   for classes in 
00003b70: 6a61 7273 2077 6974 6820 6d61 7665 6e20  jars with maven 
00003b80: 636f 6f72 642e 2e20 e294 8220 e294 80e2  coord.. ... ....
00003b90: 9480 e294 80e2 9480 e294 80e2 9480 e294  ................
00003ba0: 80e2 9480 e294 80e2 9480 e294 80e2 9480  ................
00003bb0: e294 80e2 9480 e294 80e2 9480 e294 80e2  ................
00003bc0: 9480 e294 80e2 9480 e294 80e2 9480 e294  ................
00003bd0: 80e2 9480 e294 80e2 9480 e294 80e2 9480  ................
00003be0: e294 80e2 9480 e294 80e2 9480 e294 80e2  ................
00003bf0: 9480 e294 80e2 9480 e294 80e2 9480 e294  ................
00003c00: a080 e294 80e2 9480 e294 80e2 9480 e294  ................
00003c10: 80e2 9480 e294 80e2 9480 e294 80e2 9480  ................
00003c20: e294 80e2 9480 e294 80e2 9480 e294 80e2  ................
00003c30: 9480 e294 80e2 9480 e294 80e2 9480 e294  ................
00003c40: 80e2 9480 e294 80e2 9480 e294 80e2 9480  ................
00003c50: e294 80e2 9480 e294 80e2 9480 e294 80e2  ................
00003c60: 9480 e294 80e2 9480 e294 80e2 9480 e294  ................
00003c70: 80e2 9480 e294 80e2 9480 e294 80e2 9480  ................
00003c80: e294 80e2 9480 e294 80e2 9480 e294 80e2  ................
00003c90: 9480 e294 80e2 9480 e294 80e2 9480 e294  ................
00003ca0: 80e2 9480 e294 80e2 9480 e294 80e2 9480  ................
00003cb0: 2020 2020 2020 2020 2020 2020 2020 2020                  
00003cc0: 2020 2020 2020 2020 2020 2020 2020 2020                  
00003cd0: 2020 2020 2020 2020 2020 2020 2020 2020                  
00003ce0: 2020 2020 20e2 9482 0a20 202a 2037 6663       ....  * 7fc
00003cf0: 6431 6230 204a 696e 626f 2057 616e 6720  d1b0 Jinbo Wang 
00003d00: 5570 6461 7465 2074 6865 2073 7570 706f  Update the suppo
00003d10: 7274 6564 2066 6561 7475 7265 7320 6c69  rted features li
00003d20: 7374 2069 6e20 5245 4144 4d45 2028 3320  st in README (3 
00003d30: 6d6f 6e74 6873 2061 676f 2920 2020 2020  months ago)     

There is a 0xA0 (non-breaking space?) got squeezed into a bunch of U+02500/0xE29480 (box drawings light horizontal) for some reason. Visually it looked alright:

image

Since in terminal there are sometimes weird control/drawing characters, I wonder if it's possible to ignore them?

Piping to xclip is missing

This sample (for tmux 2.4+) defines a extract-mode that you enter with X and then use p to extract paths or u for urls (piping to xclip)

I think the piping to xclip part was forgotten in the example, and I actually cannot come up a proper syntax to do it myself... Could you help out?

I want to pipe to xclip -selection clipboard

[Feature Request] Support remote headless linux server?

I've been heavy user of this plugin since I discover it years ago, and really enjoyed using it.

However, as I'm now working with more and more headless linux server (where no X server is running), the <prefix> enter solution won't work as there're either xsel or xcopy will not work(they both relies on a running X server).

My daily workflow is to use iTerm2(from macOS) to ssh to remote headless linux server(where tmux server is running). Thanks to iTerm2's "Applications in terminal may access clipboard" feature, the native tmux copy-mode-vi selection and copy way (i.e. using Space to start-selection and Enter to copy-selection-and-cancel) works, i.e. any content copied in the linux box can be directly pasted in macOS. I'm wondering if we can utilize this same approach to copy remote content when there're no X servers running remotely?

Can I work with a substring of the fuzzy match?

First off, I love this plugin! Thank you.

So let's say I've got a long URL like http://thisissomesubdomain.example.com in my pane. Now I want to do a DNS lookup on it or whatever so I know I don't want the protocol. If I fuzzy match and press tab, I get the whole string. Is there a way for me to narrow things down so I don't have to paste and then edit my command line before pressing enter?

Search Multiple Panes

Is there a way to search all the panes on the current window?

Thanks! Amazing Tool!

Stopped working

Hi, thanks for this plugin.

Recently the plugin stopped working (nothing happens after ctrl-b anymore). I can't remember changing something, except regular system updates. I'm not sure how can I supply information to debug this though. Installed via tpm:

Bash: GNU bash, version 4.4.23(1)-release (x86_64-unknown-linux-gnu)
Tmux: tmux 3.1c
Fzf: 0.22.0

Feature Request: Use fzf-tmux instead of tmux popup

When running fzf --layout=default inside tmux popup, the position of the fzf prompt at the bottom is incorrect

Example

$ tmux popup
$ fzf --layout=default

Now compare that with the following:

$ fzf-tmux -p --layout=default

Which seems to work properly

I think switching to fzf-tmux would solve this layout issue with extrakto

Happy to help with a PR

Some words are not caught by ektrakto

Hi,

I am new to using extrakto (which really seems like a great great tool btw).
I have noticed that not all words come up in the fzf selection window.
For example, with a simple ls or ls -1, some files/dirs of the listing do not show up in the fzf selection window, and since video is worth a million words, here is an asciicinema video for better visualization: https://asciinema.org/a/yxkPmJSyShMe4g2XOIypywKWC (please not this should only be available for 7 days).
In the video, the file "rofi" and directory "work" are not shown (actually I could have written those words to be sure, but I can assure you, it's not there).

tmux-extrakto.sh: line 35: fzf: command not found

I get command not found for fzf even after installing fzf as documented. I don't know the reason this happens for me though, I've created a simple sample.sh script with:

#!/bin/bash

fzf --help

When running ./sample.sh, I get the fzf help just fine.

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.