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

Add --from-history flag #8

Closed
alicederyn opened this issue Jan 24, 2022 · 2 comments
Closed

Add --from-history flag #8

alicederyn opened this issue Jan 24, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@alicederyn
Copy link
Owner

alicederyn commented Jan 24, 2022

It would be very convenient for rex to offer a --from-history flag, where it captures all the current shell's history, back to whatever the last git command was, and drop into an editor for a commit message with said commands listed in a script block.

This feature is likely to have a lot of subtle complexities to worry about; for instance, certain git commands like diff are a common part of establishing that a command has done what the user anticipated, so should be skipped over in the history.

Should respect the core.editor config, if set.

@alicederyn alicederyn added the enhancement New feature or request label Jan 24, 2022
@alicederyn
Copy link
Owner Author

alicederyn commented Jan 24, 2022

Note that I'm not sure if this feature is actually possible (i.e. whether a script can access the history of the invoking shell). Experimentation suggests a bash script can access its parent's history, but I suspect this is because it is run within the same process for efficiency; calling into bash via a python subprocess call returns a blank history.

It would be possible to grab commands from $HISTFILE (as an undocumented feature since by default it is not updated until the shell is closed), but they will be interleaved with commands from other shells in a way we cannot untangle.

@alicederyn
Copy link
Owner Author

Closing as this feature appears to be impossible to implement cleanly.

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

No branches or pull requests

1 participant