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

prompt does not show after jump when fzf is enabled #186

Open
trbjo opened this issue Jul 16, 2023 · 10 comments
Open

prompt does not show after jump when fzf is enabled #186

trbjo opened this issue Jul 16, 2023 · 10 comments

Comments

@trbjo
Copy link

trbjo commented Jul 16, 2023

zsh does not redraw my prompt when I jump with fzf. Does anyone else have the same problem?

Look how fzf ensures the prompt is redrawn after https://github.com/junegunn/fzf/blob/3c09c77269d848f5e7dd8f350a90e8d7ed760845/shell/key-bindings.zsh#L88

@kang8
Copy link
Contributor

kang8 commented Jul 18, 2023

zsh does not redraw my prompt when I jump with fzf

Please clarify. When using fzf integration in z.lua, should it be clean prompt after jumping to the directory.

@Marskey
Copy link

Marskey commented Aug 1, 2023

我也有这个问题,通过fzf, 选择一个路径后,prompt没有刷新,实际目录已经跳转过去了。

@kang8
Copy link
Contributor

kang8 commented Aug 2, 2023

我也有这个问题, 通过 fzf, 选择一个路径后,prompt 没有刷新,实际目录已经跳转过去了

I also have this problem. Through fzf, after selecting a path, the prompt is not refreshed and the actual directory has been redirected.

实际上这并不是一个问题,就是这么设计的,或者我没有找到 prompt 刷新的方法(我花了三天的空余时间来查看文档并实现这个功能,如果你有更好的方式欢迎提交 PR 去修改它)。

In fact, this is not a problem, it's designed this way, or I haven't found the method to refresh the prompt (I spent three days of my spare time reviewing the documentation and implementing this feature, if you have a better way feel free to submit a PR to modify it).

如果 fzf 跳转让你感到困惑,在初始化时删除 fzf 即可,它会回到之前的功能。

If fzf complete makes you feel confused, you can delete fzf during init, and it will return to its previous function.

- eval "$($ZLUA_EXEC $ZLUA_SCRIPT --init zsh once enhanced fzf)"
+ eval "$($ZLUA_EXEC $ZLUA_SCRIPT --init zsh once enhanced)"

@rrpolanco
Copy link

I'm running into the same issue where my prompt does not get updated/refreshed after selecting a destination with fzf.
This is how I've installed z.lua:

export _ZL_ADD_ONCE=1
export _ZL_DATA="$XDG_DATA_HOME/z.lua/database"
export _ZL_ECHO=1
export _ZL_HYPHEN=1
export _ZL_MATCH_MODE=1
export _ZL_ROOT_MARKERS=".git,.svn,.hg,.root,package.json"

zinit wait lucid light-mode for \
  has'lua' \
  atclone'mkdir -p "$(dirname "$_ZL_DATA")"; touch "$_ZL_DATA"' \
  id-as'auto' \
  @skywind3000/z.lua

Here's what I see. I select the ~/Downloads directory but my prompt does not update until I hit Enter again.

zlua_issue_186

@kang8
Copy link
Contributor

kang8 commented Sep 20, 2023

Hi @rrpolanco

What prompt framework do you use? (I use starship1, have not encountered such a problem)

2023-09-20 09 19 45

Footnotes

  1. https://starship.rs/

@rrpolanco
Copy link

Hi @kang8, I'm using powerlevel10k to render my prompt. Maybe there is some setting I need to set in p10k to redraw the prompt.

@romkatv
Copy link

romkatv commented Sep 20, 2023

Does z.lua invoke precmd hooks before resetting prompt? If not, this explains why it doesn't work with powerlevel10k. You can invoke the hooks like this:

local f
for f in precmd ${precmd_functions[@]}; do
  [[ "${+functions[$f]}" == 0 ]] || "$f" &>/dev/null || true
done

@skywind3000
Copy link
Owner

skywind3000 commented Sep 20, 2023

z.lua should be initialized before powerlevel10k, but the zsh code is written by other contributor and I don't know how to improve it:

z.lua/z.lua

Lines 2233 to 2251 in 7f2bfcb

local script_init_zsh = [[
_zlua_precmd() {
(_zlua --add "${PWD:a}" &)
}
typeset -ga precmd_functions
[ -n "${precmd_functions[(r)_zlua_precmd]}" ] || {
precmd_functions[$(($#precmd_functions+1))]=_zlua_precmd
}
]]
local script_init_zsh_once = [[
_zlua_precmd() {
(_zlua --add "${PWD:a}" &)
}
typeset -ga chpwd_functions
[ -n "${chpwd_functions[(r)_zlua_precmd]}" ] || {
chpwd_functions[$(($#chpwd_functions+1))]=_zlua_precmd
}
]]

@romkatv , does the index of precmd_functions array relate to the precmd execution order ?
If so, how to modify the zsh initializing code to put z.lua to the first one ?

mfussenegger added a commit to mfussenegger/dotfiles that referenced this issue Oct 5, 2023
@hmgle
Copy link

hmgle commented Jan 31, 2024

I also encountered this issue. However, after adding the fzf-tab plugin wrapper for zsh, the problem disappeared even when zlua was initialized with the fzf option.

Perhaps using fzf through fzf-tab is a better choice.

@FelipeLema
Copy link

FelipeLema commented Aug 23, 2024

Perhaps using fzf through fzf-tab is a better choice.

doing z something<TAB> works differently with/without fzf in z.lua init, tho

NOTE: using cloud theme

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

8 participants