Git Product home page Git Product logo

xontrib-fzf-widgets's Introduction

FZF Widgets for Xonsh ======================

License

Pypi version

This extension will add some fzf widgets to your xonsh shell that you can bind and use as follows:

Current widgets

  • ssh: Search in /etc/ssh/ssh_config or ~/.ssh/config items and issue ssh command on the chosen item.
  • history insert Search in all history entries and insert the chosen command to the prompt.

How to use it

Install the package:

pip install xontrib-fzf-widgets

Enable it by adding fzf-widgets to your ~/.config/xonsh/config.json file:

{
  "xontribs": [
    ...,
    "fzf-widgets"
  ]
}

And set your desired keybindings for each widget in ~/.xonshrc file or set it to None to disable it:

$fzf_history_binding = Keys.ControlR
$fzf_ssh_binding = Keys.ControlS

xontrib-fzf-widgets's People

Contributors

bovine3dom avatar shahinism avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

xontrib-fzf-widgets's Issues

Silent error every time the widget is open

Whenever I open widget I get the following error

xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
NameError: name 'Keys' is not defined
error running xonsh run control file '/home/nlehmann/.xonshrc':  name 'Keys' is not defined

Then the error disappears and fzf works normally. In my xonshrc I have the following:

$fzf_history_binding = Keys.ControlR
$fzf_ssh_binding = Keys.ControlS

peek

AttributeError: 'KeyBindings' object has no attribute 'registry'

xonsh: To log full traceback to a file set: $XONSH_TRACEBACK_LOGFILE = <filename>
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/xonsh/__amalgam__.py", line 8436, in _call
    handler(**self._kwargs)
  File "/usr/local/lib/python3.7/site-packages/xontrib/fzf-widgets.xsh", line 57, in custom_keybindings
    @handler('fzf_history_binding')
  File "/usr/local/lib/python3.7/site-packages/xontrib/fzf-widgets.xsh", line 53, in handler
    return bindings.registry.add_binding(key)
AttributeError: 'KeyBindings' object has no attribute 'registry'
Exception raised in event handler; ignored.

TypeError: error() takes 0 positional arguments but 1 was given

When fzf is not in PATH I get and I press Ctrl+R with xontrib-fzf-widgets enabled, I get:

xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
TypeError: error() takes 0 positional arguments but 1 was given

I think this is due to

class RequiredCommand:
    def __init__(self, cmd):
        self.cmd = check_command(cmd)

    def __call__(self, func):
        def error():
            print("fzf-widgets: command not found: {}".format(self.cmd))

the def error() apparently needs to accept an argument; changing it to this fixes it for me:

        def error(event):
            print("fzf-widgets: command not found: {}".format(self.cmd))

The thing that's apparently passed in is a <class 'prompt_toolkit.key_binding.input_processor.KeyPressEvent'>.

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.