Skip to main content

fish_functions/fish_prompt: fix Git repo issues

ID
4833417
date
2026-04-13 20:35:03+00:00
author
Alex Chan <alex@alexwlchan.net>
parent
8984cd5
message
fish_functions/fish_prompt: fix Git repo issues
changed files
1 file, 24 additions, 25 deletions

Changed files

fish_functions/fish_prompt.fish (5274) → fish_functions/fish_prompt.fish (5205)

diff --git a/fish_functions/fish_prompt.fish b/fish_functions/fish_prompt.fish
index d80efc1..e94df46 100644
--- a/fish_functions/fish_prompt.fish
+++ b/fish_functions/fish_prompt.fish
@@ -26,33 +26,32 @@ end
 # shell prompt.
 function print_git_information
     which git 2>&1 >/dev/null
-    
-    if git rev-parse --is-bare-repository 2>/dev/null >/dev/null
-        return
+
+    set is_bare (git rev-parse --is-bare-repository 2> /dev/null)
+    if string match $is_bare "false\n"
+        true
     end
-    
-    if [ $status = 0 ]
-        set branch (git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
-        if [ -n "$branch" ]
-            set_color normal
-            printf " on git:"
-
-            if test (basename "$branch") = main
-                set_color cyan
-            else
-                set_color purple
-            end
-
-            printf "$branch"
-
-            # Print an asterisk to indicate uncommitted changes, if there are any
-            # Try git update-index --really-refresh?
-            if ! git diff-index --quiet HEAD --
-                printf "*"
-            end
-
-            set_color normal
+
+    set branch (git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')
+    if [ -n "$branch" ]
+        set_color normal
+        printf " on git:"
+
+        if test (basename "$branch") = main
+            set_color cyan
+        else
+            set_color purple
+        end
+
+        printf "$branch"
+
+        # Print an asterisk to indicate uncommitted changes, if there are any
+        # Try git update-index --really-refresh?
+        if ! git diff-index --quiet HEAD --
+            printf "*"
         end
+
+        set_color normal
     end
 end