bashhub-client
bashhub-client copied to clipboard
Feature Request: Select command but do not execute it.
It would be nice to be able to select a command and have it filled on the cli but not be executed right away.
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
closing as I don't believe this is possible in bash. This is the default behavior in Zsh.
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"
I think I got the inspiration from https://github.com/dvorka/hstr
@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.
I think so - https://docs.python.org/3.8/library/fcntl.html
I'll see if I can figure it out
Looking into this a bit more, found a few other threads with similar or other ways of approaching this.
- https://unix.stackexchange.com/questions/213799/can-bash-write-to-its-own-input-stream/217390
- https://unix.stackexchange.com/questions/391679/how-to-automatically-insert-a-string-after-the-prompt
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.
Any news? In my case, on mac the selected entry is just printed and not filled or executed
@weeebdev what do you mean by 'just printed and not filled or executed'? Also what shell are you running?
@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