Git Product home page Git Product logo

Comments (4)

sxyazi avatar sxyazi commented on August 16, 2024

I don't think this makes sense because Yazi's commands are executed concurrently. The show-input command needs to wait for user input, so it's an asynchronous command. This means the shell command will execute immediately without waiting for show-input.

Also, while show-input is running, any background plugin could interrupt it (plugins have full control over the input component), leading to incorrect shell parameters unless we introduce additional execution state between commands.

In Yazi, plugins are first-class citizens. The functionality you're describing can easily be implemented through the plugin system and would make a great general-use plugin. What you're asking for is very similar to https://github.com/Ape/open-with-cmd.yazi.

Given these reasons I'm going to close this issue as it's not in the plan.

from yazi.

wojciech-kulik avatar wojciech-kulik commented on August 16, 2024

I tried to create such a plugin, but with the current syntax of args it looks pretty messy. Imagine something like that:

run = "plugin --async run-with-input --args='--block --confirm --title=\"Archive name:\" --command=\"zip %s $@\"'"

and it is just for a simple case. That's why it would be better to have it built-in. As you said, the current implementation wouldn't work because of asynchronous issues. So maybe, there could be introduced a different mechanism for such case?

Like:

run_with_input = "shell --block --confirm 'zip %s.zip $@'" , input_title = "Archive:" 

However, I understand if you don't want to introduce more options in the config and if you prefer to delegate such cases to Lua.

from yazi.

sxyazi avatar sxyazi commented on August 16, 2024

I plan to simplify the shell and plugin commands in the next target (0.3.1) by adding macros. At that point, you'll be able to write it as:

!run-with-input "zip %s $@" --block --title="Archive name:"

where !run-with-input represents plugin run-with-input --args='...' (note that the plugin command doesn't have the --async flag because it's asynchronous by default).

The --confirm option will also be deprecated in the next target, as it will no longer be necessary once we require the explicit --interactive option.

Similarly, shell commands will also be simplified. For example, shell --block --confirm 'echo "$@"' can be written as :echo "$@".

I believe that through this series of simplifications, it will allow plugins to be more expressive.

from yazi.

wojciech-kulik avatar wojciech-kulik commented on August 16, 2024

Sounds great! Those changes will simplify keymaps a lot.

from yazi.

Related Issues (20)

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.