<

Ruben

/>

You need a fancy async prompt, and here's why

dotfiles

 ⋅ July 24, 2017 ⋅ 2 min read

Screenshot of an example prompt
Screenshot of an example prompt

Modern programming involves an abusive amount of terminal usage.

  • Test changes? Terminal.
  • Launch server? Terminal.
  • Commit changes? Terminal.
  • Docker? Terminal.
  • Anything else? Probably terminal...
  • Using VIM? Always terminal.

Now imagine the core tool of your workflow looking like this:

Default prompt
Default prompt

Doesn't seem very pleasant, does it?

It's all about the eye candy

Communities like /r/unixporn (it's SFW for the record) aim to solve that issue, by providing eye candy for our trusty terminals:

Prompt with eyecandy
Prompt with eyecandy

Looks much better, right? But we can't stop now...

We need more statuses!

Even more eye candy
Even more eye candy

NOTE: Screenshots are from Powerlevel9K's config showoff.

Overall a much better experience, except for all the overhead you get from running git status and nvm version every single time you press ENTER.

Slow terminal response issues are really common, even outside of Powerlevel9K.

It's not even about relatively fancy nvm/rbenv prompt segments. VCS segments add a lot of overhead in big repos.

This is how it looks like opening a Linux Kernel repo with most of its history deleted (only 14 commits):

Granted, filesystem cache makes subsequent prompt redraws much faster, but there is still a 200-300ms delay that makes typing really annoying.

Async will help us

Here is the list of async prompts I managed to find (feel free to add yours in the comments):

NOTE: I'm going to use Powerlevel9K in this example purely because of aesthetics.

Instead of this in antigernrc (you can use whatever ZSH package manager you prefer):

POWERLEVEL9K_INSTALLATION_PATH=$ANTIGEN_BUNDLES/bhilburn/powerlevel9k
antigen theme bhilburn/powerlevel9k powerlevel9k

We are going to use the WIP branch with zsh-async:

#Async library
antigen bundle mafredri/zsh-async

#Theme
POWERLEVEL9K_INSTALLATION_PATH=$ANTIGEN_BUNDLES/dritter/powerlevel9k-async_all_the_segments/powerlevel9k.zsh-theme
antigen theme dritter/powerlevel9k powerlevel9k --branch=async_all_the_segments

Much better results!

As you might have noticed, VCS info isn't blocking us from typing into the terminal and executing commands. That's a huge usability improvement.

You can find my full zsh configuration here.

Happy coding!