Skip to main content

Ensure we refresh the Git index before checking for changes

ID
1a0bbe6
date
2024-01-18 15:51:49+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
fa37bf8
message
Ensure we refresh the Git index before checking for changes
changed files
1 file, 12 additions

Changed files

config.fish (6244) → config.fish (6668)

diff --git a/config.fish b/config.fish
index 5b591e5..e4f624e 100644
--- a/config.fish
+++ b/config.fish
@@ -90,6 +90,18 @@ function __auto_activate_venv --on-variable PWD --description "Auto activate/dea
 end
 
 
+# This updates the Git index whenever I 'cd' into a new directory.
+#
+# Not all directories are Git repos, so if it returns an error, hide it.
+#
+# This is needed for showing my Git branch in my prompt: otherwise I see
+# an asterisk for uncommitted changes until I interact with Git somehow,
+# even though there aren't any.
+function __refresh_git_indexes --on-variable PWD
+    git update-index --refresh >/dev/null 2>&1
+end
+
+
 # Load macOS-specific utilities
 if [ (uname -s) = Darwin ]
     # Provide a convenient alias for the front URL in both browsers