1. 39
  1. 3

    I’d been using https://www.anishathalye.com/2015/02/07/an-asynchronous-shell-prompt/ on a large monorepo (~60,000 files) but last night I found that gitstatus (even in synchronous mode) is still faster.

    1. 3

      Glad you found that post useful :)

      For anyone else considering following the advice in my post – I think async prompts are super nice (and I’m still using basically that same code today), but I think the implementation in the submission above is cleaner than mine. It relies on zsh-async, which I think is less hacky than the file and signal-based approach I am using.

    2. 2

      Recently switched to gitstatus for retrieving repo information and have been quite pleased by the speed and ease of integration. IMO the best solution would be the shell itself subscribing to file system change notifications and recomputing the status ahead of time, but this is a great step toward that. (Aside: does zsh support native plugins?)

      In my zshrc you can see how I integrated gitstatus.

      1. 2

        For anyone who wants to see a demo of a difference this makes in practice, here’s a GIF comparing a synchronous prompt with a async one when cding into the Linux kernel source (with an empty buffer cache).

        1. 1

          This is really cool.

          When i came to $DAYJOB and brought my oh my zsh config, it hung infinitely trying to hoover up our mammoth repositories :)

          I’ve since given up on zsh since our entire ship is SUPER bash heavy, but maybe I could steal some of this and get my beloved dirty indicator back :)

          1. 1

            I’ve been using a fork of https://github.com/sindresorhus/pure – which also supports asynchronous git status checking – after getting frustrated from a synchronous git status check a few years ago. It’s been working really well for me!

            1. 1

              Please share!

              1. 1

                Here’s my fork: https://github.com/bkase/pure

            2. 1

              A few of us wrote a small zsh prompt called geometry that centers a bit around this idea. You define two arrays, one for left prompt, one for right prompt. The right prompt functions are all called and updated async, left prompt sync. We ship a decent amount of functions that are defined but not enabled. Kinda looks like this:

              function slowhi() { sleep 7 && echo 'hi!' }
              GEOMETRY_PROMPT=(geometry_status geometry_path)
              GEOMETRY_RPROMPT+=(pwd slowhi)
              1. 1

                Cool concept. I tried to run this but it starts running into this error after a few updates

                geometry::rprompt:2: can't clobber parameter GEOMETRY_ASYNC_FD containing file descriptor 11

                Secondly, I noticed with the slowhi example here that the whole RPROMPT only updates after 7 seconds. Somehow I thought async function updates completing independently would make RPROMPT update with them.

                1. 1

                  Thanks for testing it! Made an issue https://github.com/geometry-zsh/geometry/issues/286 for tracking

              2. 1

                There is also https://github.com/romkatv/powerlevel10k which has a pure-like theme.