aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cfg/fish/fish_prompt.fish9
1 files changed, 7 insertions, 2 deletions
diff --git a/cfg/fish/fish_prompt.fish b/cfg/fish/fish_prompt.fish
index 355539b..8ff31f5 100644
--- a/cfg/fish/fish_prompt.fish
+++ b/cfg/fish/fish_prompt.fish
@@ -14,7 +14,12 @@ function fish_prompt
set prompt_sym "#"
end
+ set -l in_git false
if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true"
+ set in_git true
+ end
+
+ if test "$in_git" = "true"
#set branch (git branch --show-current 2>/dev/null)
set branch (git branch --show-current 2>/dev/null); or set branch (git rev-parse --short HEAD 2>/dev/null)
set branch "$branch_sym"(set_color red)"$branch"
@@ -39,7 +44,7 @@ function fish_prompt
set colored (string trim -r -c "/" $colored)
# if in a ~ subdir
- if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true"
+ if test "$in_git" = "true"
echo -e (set_color white)"$pr_prefix"(set_color red)"$user"(set_color white)" $at_sym "(set_color red)"$colored"\
(set_color white)"$on_sym ""$branch"(set_color white)"\n" \
(set_color white)"$prompt_sym "(set_color normal)
@@ -60,7 +65,7 @@ function fish_prompt
set colored (string trim -r -c "/" $colored)
set colored (set_color red)"$root_dir_sym""$colored"
# if in any other dir
- if test "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = "true"
+ if test "$in_git" = "true"
echo -e (set_color white)"$pr_prefix"(set_color red)"$user"(set_color white)" $at_sym "(set_color red)"$colored"\
(set_color white)"$on_sym ""$branch"(set_color white)"\n" \
(set_color white)"$prompt_sym "(set_color normal)