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

Inject into zsh history #5

Merged
merged 1 commit into from
Mar 15, 2023
Merged

Conversation

backus
Copy link
Owner

@backus backus commented Mar 15, 2023

I found myself instinctively using ctrl+r after using this tool to rerun commands that I originally ran via this AI helper. I want those commands in my ZSH history as if I ran them.

Unfortunately, you can't call print -s from a subshell to write to the zsh history. It only works if the call originates from the user's shell and not a script. To workaround that, I replicate the timestamp prefix that my ZSH history file uses and then I inject into the history manually.

I found myself instinctively using ctrl+r after using this tool
to rerun commands that I originally ran via this AI helper. I want
those commands in my ZSH history as if I ran them.

Unfortunately, you can't call `print -s` from a subshell to write
to the zsh history. It only works if the call originates from the
user's shell and not a script. To workaround that, I replicate the
timestamp prefix that my ZSH history file uses and then I inject into
the history manually.
@backus backus force-pushed the feature/inject-into-zsh-history branch from 89532a6 to 4474913 Compare March 15, 2023 22:46
@backus backus merged commit 5eda487 into master Mar 15, 2023
@backus backus deleted the feature/inject-into-zsh-history branch March 15, 2023 22:47
@backus backus mentioned this pull request Mar 15, 2023
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

Successfully merging this pull request may close these issues.

1 participant