reedline icon indicating copy to clipboard operation
reedline copied to clipboard

ExecuteHostCommand doesnt run the command

Open alexzanderr opened this issue 2 years ago • 7 comments

hello

im trying to run a simple command that returns output

i've modified the demo example by adding a new keybiding:

fn add_extra_keybindings(keybindings: &mut Keybindings) {
    // This doesn't work for macOS
    keybindings.add_binding(
        KeyModifiers::CONTROL,
        KeyCode::Char('f'),
        ReedlineEvent::ExecuteHostCommand("echo 'its working'".into()),
        // doesnt work
        // ReedlineEvent::ExecuteHostCommand(
        //     "/usr/bin/exa --all --icons".into(),
        // ),
    );
}

here i've setup the binding ctrl+f to run the command echo 'its working'

what im expecting: reedline to print the output of the command in the prompt, just like a real shell. isnt that the expected behaviour?

what im getting instead is:

Our buffer: echo 'its working'
prompt 〉

that indicates that the buffer state after running the command is the command itself.

i want the output to be printed in the terminal or maybe run another inner prompt that gets input which then will exit the result into reedline.

what am i missing?

i've looked a little in the source: engine.rs

            ReedlineEvent::ExecuteHostCommand(host_command) => {
                // TODO: Decide if we need to do something special to have a nicer painter state on the next go
                Ok(EventStatus::Exits(Signal::Success(host_command)))
            }

but im not seeing any Command::new().arg() ... .spawn() etc, rusty stuff here; just a signal success with the command as string

is this code running the command? seems to not.

thanks in advance.

more advanved extra topic: how can i run an external shell command that prompts a UI, for example skim the fuzzy finder inside reedline? (but that is after im solving the first problem)

alexzanderr avatar Dec 23 '22 09:12 alexzanderr