Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Select command but do not execute it. #85

Open
Gibby opened this issue Jul 28, 2020 · 10 comments
Open

Feature Request: Select command but do not execute it. #85

Gibby opened this issue Jul 28, 2020 · 10 comments

Comments

@Gibby
Copy link

Gibby commented Jul 28, 2020

It would be nice to be able to select a command and have it filled on the cli but not be executed right away.

@rcaloras
Copy link
Owner

Hey @Gibby, thanks for the feedback. This is actually the default behavior for bashhub with Zsh. In Bash this is unfortunately not possible as far as I'm aware.

I originally tried to build this and actually asked about it on Stackoverflow years back: https://stackoverflow.com/questions/22951608/python-or-bash-print-output-to-command-line-ready-to-be-executed

@rcaloras
Copy link
Owner

rcaloras commented Aug 2, 2020

closing as I don't believe this is possible in bash. This is the default behavior in Zsh.

@rcaloras rcaloras closed this as completed Aug 2, 2020
@Gibby
Copy link
Author

Gibby commented Aug 3, 2020

I got this working on both Ubuntu and Mac in bash by adding the following function.

_bh_inject() {
  perl -e 'ioctl(STDIN, 0x5412, $_) for split "", join " ", @ARGV' "$@"
}

Then I changed these lines.

    #echo "$command"
    #eval "$command"
    __bh_precmd
    _bh_inject "$command"

@Gibby
Copy link
Author

Gibby commented Aug 3, 2020

I think I got the inspiration from https://github.com/dvorka/hstr

@rcaloras
Copy link
Owner

rcaloras commented Aug 3, 2020

@Gibby thanks for sharing! any idea if this possible using python? wondering to avoid adding a dependency on perl.

Feel free to submit a PR as well if you're interested :) Would be happy to make this the default experience.

@rcaloras rcaloras reopened this Aug 3, 2020
@Gibby
Copy link
Author

Gibby commented Aug 3, 2020

I think so - https://docs.python.org/3.8/library/fcntl.html

I'll see if I can figure it out

@rcaloras
Copy link
Owner

Looking into this a bit more, found a few other threads with similar or other ways of approaching this.

Hacking at it a bit and haven't been able to get anything to work quite yet. Tried the python solution mentioned here and also tried using autopy.

@Gibby, please share if you find something viable on Python or just bash.

@weeebdev
Copy link

Any news? In my case, on mac the selected entry is just printed and not filled or executed

@rcaloras
Copy link
Owner

@weeebdev what do you mean by 'just printed and not filled or executed'? Also what shell are you running?

@weeebdev
Copy link

weeebdev commented Nov 2, 2022

@weeebdev what do you mean by 'just printed and not filled or executed'? Also what shell are you running?

fish shell. I meant, that when I pick a command from the history, it's just being printed in the console but not actually executed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants