1
Fork 0
mirror of https://github.com/RGBCube/nu_scripts synced 2025-08-01 06:37:46 +00:00
nu_scripts/modules/prompt/async_git_prompt
Stefan Holderbach 6947014306
Replace use of $nothing with null (#621)
`$nothing` will be deprecated in nu 0.86

This accompanies
- https://github.com/nushell/nushell/pull/10478
2023-09-26 18:52:49 +02:00
..
async-git-prompt.nu refactor: (#418) 2023-04-25 17:56:25 -05:00
prompt.nu Replace use of $nothing with null (#621) 2023-09-26 18:52:49 +02:00
README.md refactor: (#418) 2023-04-25 17:56:25 -05:00

This module exports commands for creating a nushell prompt that computes git status (staged and unstaged changes) asynchronously. This can be useful in large git repos when it is slow to obtain this information synchronously.

To use this module:

  1. Place the file async-git-prompt.nu in the $nu.config-path directory (this is the directory containing init.nu and env.nu).

  2. Use the command async-git-prompt-string in your own PROMPT_COMMAND (the file prompt.nu contains an example of doing this.) At this point, your prompt will be computing the information synchronously, because the cache file does not yet exist.

  3. In a repo where git is slow, run the command async-git-prompt-refresh-cache. Now, your prompt will be fast, but it also won't update automatically. You could investigate a good way to invalidate the cache automatically, but the manual alternative is:

  4. Whenever you think your prompt might be stale, re-run the command async-git-prompt-refresh-cache. Your prompt will update on one of the next times that you hit .

  5. It will probably be convenient to alias this, e.g.

    alias r = async-git-prompt-refresh-cache
    
  6. To go back to synchronous mode, run async-git-prompt-delete-cache.

TODO

  • Automatic cache invalidation
  • Show untracked files (this can be very expensive in large repos)