acomagu/fish-async-prompt

FR: I'd like the prompt redrawn when the terminal with fish gains focus

ilyagr opened this issue · 2 comments

I'd love the time and the current commit to be updated when I switch to a different shell.

This could be doable with the https://github.com/fish-shell/fish-shell/blob/8880fa8dd7f868f2c098b7b845caab2affc2e4f9/doc_src/language.rst?plain=1#L2095 event.

(Separately, an option to redraw the prompt every minute would also be nice. I can file a separate FR for this. #78 )

As far as I can tell, the following is "supposed" to work (see fish-shell/fish-shell#6394 (comment)), but doesn't with fish_async_prompt.

function fish_focus_in --on-event fish_focus_in
    commandline -f repaint
end

See also https://fishshell.com/docs/current/cmds/bind.html#special-input-functions for repaint and https://fishshell.com/docs/current/cmds/commandline.html

This seems to work (maybe?):

function fish_focus_in --on-event fish_focus_in
    __async_prompt_fire
    # commandline -f paint  # Not sure whether this helps or hurts.
end

Is this the correct way? I think it'd be nice if this was "officially" supported with a non-__ function.