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

Multiple shells in the same folder do not share history #27

Open
piegamesde opened this issue Apr 9, 2019 · 12 comments
Open

Multiple shells in the same folder do not share history #27

piegamesde opened this issue Apr 9, 2019 · 12 comments

Comments

@piegamesde
Copy link

How to reproduce the problem

  1. Open a shell in a folder, and type echo hello.
  2. Open a second shell in that same folder and type echo world.
  3. In both shells, use the arrow keys to view their respective history.

What happens

Each shell does not contain the history of the other, albeit them being in the same folder. Sometimes, toggling to global and back makes the entries appear in the history, but a little in the wrong order.

What should happen

All shells in the same folder have a shared history.

@jimhester
Copy link
Owner

Have you set the following?

setopt inc_append_history
setopt share_history

@piegamesde
Copy link
Author

Yes and no:

~ » setopt
[...]
incappendhistory
[...]
sharehistory
[...]

@CyberShadow
Copy link

I think this is the same general problem as #21 (comment).

@jimhester
Copy link
Owner

I am pretty sure this used to work fine, and AFAIK is still works on older versions of zsh with the current implementation. @CyberShadow if your new implementation does not lose features compared to the current one could you open a PR so we could discuss it there?

@CyberShadow
Copy link

if your new implementation does not lose features compared to the current one

Frankly I have no idea if it does, it definitely needs wider testing before we could say that it satisfies assumptions like that. It started out as a personal hack, and only after some non-trivial time investment to get it working the way I wanted that I realized that it could be useful for a wider audience.

@CyberShadow
Copy link

Also, thank you for your work on this script! :)

@piegamesde
Copy link
Author

Your branch kind of works. If I type echo hello on one shell and echo world on another, the latter one will find echo hello in its history. But the first one won't have echo world until I issue another command, after which it will contain echo world as well. It only works with global history, even if both shells are in the same folder.

@CyberShadow
Copy link

But the first one won't have echo world until I issue another command

You have to hit RET to get ZSH to reload history. As far as I know, this is true even without any per-directory history or other history customizations.

It only works with global history, even if both shells are in the same folder.

Could you please describe this problem in more detail and how to reproduce it?

FWIW, I tested with append_history + extended_history + inc_append_history + share_history.

@piegamesde
Copy link
Author

Shell 1:

cd ~
setopt append_history extended_history inc_append_history share_history
echo hello

Shell 2:

cd ~
setopt append_history extended_history inc_append_history share_history
echo world

This does not share the history in local history mode.

@CyberShadow
Copy link

@seivan
Copy link

seivan commented Mar 2, 2021

Have you set the following?

setopt inc_append_history
setopt share_history

According to the docs INC_APPEND_HISTORY is unecessary when you got sharehistory

@kezhenxu94
Copy link

I am pretty sure this used to work fine, and AFAIK is still works on older versions of zsh with the current implementation. @CyberShadow if your new implementation does not lose features compared to the current one could you open a PR so we could discuss it there?

Hi @jimhester @CyberShadow , I also encounter this issue and after comparing the commit of #21 (comment) and the latest master branch, I ported the CyberShadow@b8e7a96 to the master branch #55 and that fixes the issue for me, can you take a look?

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 a pull request may close this issue.

5 participants