shell-ai icon indicating copy to clipboard operation
shell-ai copied to clipboard

Feature Request: insert selected commands in shell history

Open element303 opened this issue 2 years ago • 5 comments

is it possible to insert selected commands in shell history ?

element303 avatar Aug 23 '23 08:08 element303

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?

ricklamers avatar Aug 23 '23 08:08 ricklamers

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...

element303 avatar Aug 23 '23 09:08 element303

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.

JamesHutchison avatar Aug 24 '23 05:08 JamesHutchison

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

rvangsgaard avatar Aug 30 '23 08:08 rvangsgaard

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

ricklamers avatar Sep 14 '23 18:09 ricklamers