ricklamers / shell-ai

LangChain powered shell command generator and runner CLI
MIT License
1.02k stars 62 forks source link

Feature Request: insert selected commands in shell history #10

Open element303 opened 1 year ago

element303 commented 1 year ago

is it possible to insert selected commands in shell history ?

ricklamers commented 1 year ago

We could append to .bash_history if it exists, right now we are pretty shell agnostic so not sure whether we want to adopt the burden of doing this for all the various shells. But zsh and bash probably divide the market so could be worth it. Wdyt?

element303 commented 1 year ago

yes it will be very usefull append .bash_history. Another project like Arsenal (by Orange Cyberdefense) have find another solution : "arsenal emulates real user input (with TTY arguments and IOCTL) so arsenal works with all shells and your commands will be in the history" (see https://github.com/Orange-Cyberdefense/arsenal) But i don't know how program that...

JamesHutchison commented 1 year ago

I think it makes sense to support zsh and bash.

My thinking is the behavior would be to append the ran command as the most recent. Pressing up again would give you the query command itself.

rvangsgaard commented 1 year ago

yes it will be very usefull append .bash_history. Another project like Arsenal (by Orange Cyberdefense) have find another solution : "arsenal emulates real user input (with TTY arguments and IOCTL) so arsenal works with all shells and your commands will be in the history" (see https://github.com/Orange-Cyberdefense/arsenal) But i don't know how program that...

This seem like the place where arsenal emulates real user input https://github.com/Orange-Cyberdefense/arsenal/blob/0cab6a6f0550e59b2a5f128905126ed52cc5220d/arsenal/app.py#L164-L180

ricklamers commented 1 year ago

We could append to .bash_history if it exists

This won't actually work, with that approach it only shows up after shell restart. I think we're going to have to go in the direction of the code @rvangsgaard linked