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

Mismatch in global history with Ctrl+R vs builtin fc command #329

Open
LangLangBart opened this issue Oct 26, 2024 · 4 comments
Open

Mismatch in global history with Ctrl+R vs builtin fc command #329

LangLangBart opened this issue Oct 26, 2024 · 4 comments

Comments

@LangLangBart
Copy link

This issue report is similar to a comment on another issue: #35 (comment)


When SHARE_HISTORY is enabled and two terminals are open, running echo Test1 in Terminal A and fc -rl -1 in Terminal B results in the following output:


If you repeat the test but instead of running fc -rl -1 in Terminal B, you use ctrl-r (z4h-fzf-history), the command from Terminal A won't appear in the z4h-fzf-history list until a dummy command is run in Terminal B.

Adding fc -RI before $history is called in z4h-fzf-history would allow the command from Terminal A to appear after simply pressing Enter in Terminal B without executing a command. Do you agree with this approach?

--- a/fn/z4h-fzf-history
+++ b/fn/z4h-fzf-history
@@ -131,4 +131,5 @@ local preview='printf "%s" {} | command cut -f2- -d'$'\1'
       unsetopt pipe_fail
       {
+        [[ "${options[sharehistory]}" == "on" ]] && fc -RI
         # This `noglob` is a workaround for a bug in zsh that can be
         # triggered by certain corrupted history files.

typeset -pm 'HISTFILE|HISTSIZE|SAVEHIST' &&
 emulate &&
 print -r -- $(setopt) &&
 zstyle -L ':z4h:*' &&
 fc -l -2 -2 &&
 print -r -- ${#${history[@]}} ${(qqq)${history[@]}[1]}

typeset HISTFILE=/Users/paria/.dotfiles/zsh/.zsh_history
typeset -i10 HISTSIZE=1000000000
typeset -i10 SAVEHIST=1000000000
zsh
alwaystoend autocd autopushd noautoremoveslash nobeep nobgnice cbases extendedglob extendedhistory noflowcontrol noglobalrcs histexpiredupsfirst histfcntllock histfindnodups histignoredups histignorespace histsavenodups histverify interactive interactivecomments nolisttypes login promptsubst sharehistory shinstdin typesetsilent
zstyle :z4h: auto-update no
zstyle ':z4h:ssh:*' enable no
zstyle :z4h:direnv enable no
zstyle ':z4h:*' fzf-command _fzf_sanitized
zstyle :z4h:bindkey keyboard mac
zstyle :z4h: start-tmux no
zstyle :z4h: term-shell-integration yes
14532  echo Test1
14532 "echo Test101"

Related

@romkatv
Copy link
Owner

romkatv commented Oct 26, 2024

How does the regular Ctrl-R in zsh behave?

@LangLangBart
Copy link
Author

How does the regular Ctrl-R in zsh behave?

pressing Enter in Terminal B is enough

@romkatv
Copy link
Owner

romkatv commented Oct 26, 2024

Is that different from Crtl-R in z4h?

@LangLangBart
Copy link
Author

LangLangBart commented Oct 26, 2024

Yes, one has to enter a command so that the $history array gets updated.

EDIT1

Related discussion:

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

No branches or pull requests

2 participants